Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view Chris@0: * the LICENSE file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Composer\Semver\Constraint; Chris@0: Chris@18: trigger_error('The ' . __NAMESPACE__ . '\AbstractConstraint abstract class is deprecated, there is no replacement for it, it will be removed in the next major version.', E_USER_DEPRECATED); Chris@0: Chris@0: /** Chris@0: * Base constraint class. Chris@0: */ Chris@0: abstract class AbstractConstraint implements ConstraintInterface Chris@0: { Chris@0: /** @var string */ Chris@0: protected $prettyString; Chris@0: Chris@0: /** Chris@0: * @param ConstraintInterface $provider Chris@0: * Chris@0: * @return bool Chris@0: */ Chris@0: public function matches(ConstraintInterface $provider) Chris@0: { Chris@0: if ($provider instanceof $this) { Chris@0: // see note at bottom of this class declaration Chris@0: return $this->matchSpecific($provider); Chris@0: } Chris@0: Chris@0: // turn matching around to find a match Chris@0: return $provider->matches($this); Chris@0: } Chris@0: Chris@0: /** Chris@0: * @param string $prettyString Chris@0: */ Chris@0: public function setPrettyString($prettyString) Chris@0: { Chris@0: $this->prettyString = $prettyString; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return string Chris@0: */ Chris@0: public function getPrettyString() Chris@0: { Chris@0: if ($this->prettyString) { Chris@0: return $this->prettyString; Chris@0: } Chris@0: Chris@0: return $this->__toString(); Chris@0: } Chris@0: Chris@0: // implementations must implement a method of this format: Chris@0: // not declared abstract here because type hinting violates parameter coherence (TODO right word?) Chris@0: // public function matchSpecific( $provider); Chris@0: }