4 * This file is part of composer/semver.
6 * (c) Composer <https://github.com/composer>
8 * For the full copyright and license information, please view
9 * the LICENSE file that was distributed with this source code.
12 namespace Composer\Semver\Constraint;
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);
17 * Base constraint class.
19 abstract class AbstractConstraint implements ConstraintInterface
22 protected $prettyString;
25 * @param ConstraintInterface $provider
29 public function matches(ConstraintInterface $provider)
31 if ($provider instanceof $this) {
32 // see note at bottom of this class declaration
33 return $this->matchSpecific($provider);
36 // turn matching around to find a match
37 return $provider->matches($this);
41 * @param string $prettyString
43 public function setPrettyString($prettyString)
45 $this->prettyString = $prettyString;
51 public function getPrettyString()
53 if ($this->prettyString) {
54 return $this->prettyString;
57 return $this->__toString();
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);