Mercurial > hg > rc1
comparison vendor/composer/semver/src/Constraint/AbstractConstraint.php @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e000243b222 |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of composer/semver. | |
5 * | |
6 * (c) Composer <https://github.com/composer> | |
7 * | |
8 * For the full copyright and license information, please view | |
9 * the LICENSE file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Composer\Semver\Constraint; | |
13 | |
14 trigger_error('The ' . __CLASS__ . ' abstract class is deprecated, there is no replacement for it, it will be removed in the next major version.', E_USER_DEPRECATED); | |
15 | |
16 /** | |
17 * Base constraint class. | |
18 */ | |
19 abstract class AbstractConstraint implements ConstraintInterface | |
20 { | |
21 /** @var string */ | |
22 protected $prettyString; | |
23 | |
24 /** | |
25 * @param ConstraintInterface $provider | |
26 * | |
27 * @return bool | |
28 */ | |
29 public function matches(ConstraintInterface $provider) | |
30 { | |
31 if ($provider instanceof $this) { | |
32 // see note at bottom of this class declaration | |
33 return $this->matchSpecific($provider); | |
34 } | |
35 | |
36 // turn matching around to find a match | |
37 return $provider->matches($this); | |
38 } | |
39 | |
40 /** | |
41 * @param string $prettyString | |
42 */ | |
43 public function setPrettyString($prettyString) | |
44 { | |
45 $this->prettyString = $prettyString; | |
46 } | |
47 | |
48 /** | |
49 * @return string | |
50 */ | |
51 public function getPrettyString() | |
52 { | |
53 if ($this->prettyString) { | |
54 return $this->prettyString; | |
55 } | |
56 | |
57 return $this->__toString(); | |
58 } | |
59 | |
60 // implementations must implement a method of this format: | |
61 // not declared abstract here because type hinting violates parameter coherence (TODO right word?) | |
62 // public function matchSpecific(<SpecificConstraintType> $provider); | |
63 } |