123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- /*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Symfony\Bridge\PhpUnit\Legacy;
- use SebastianBergmann\Exporter\Exporter;
- /**
- * @internal
- */
- trait ConstraintTraitForV6
- {
- /**
- * @return bool|null
- */
- public function evaluate($other, $description = '', $returnResult = false)
- {
- return $this->doEvaluate($other, $description, $returnResult);
- }
- /**
- * @return int
- */
- public function count()
- {
- return $this->doCount();
- }
- /**
- * @return string
- */
- public function toString()
- {
- return $this->doToString();
- }
- /**
- * @param mixed $other
- *
- * @return string
- */
- protected function additionalFailureDescription($other)
- {
- return $this->doAdditionalFailureDescription($other);
- }
- /**
- * @return Exporter
- */
- protected function exporter()
- {
- if (null === $this->exporter) {
- $this->exporter = new Exporter();
- }
- return $this->exporter;
- }
- /**
- * @param mixed $other
- *
- * @return string
- */
- protected function failureDescription($other)
- {
- return $this->doFailureDescription($other);
- }
- /**
- * @param mixed $other
- *
- * @return bool
- */
- protected function matches($other)
- {
- return $this->doMatches($other);
- }
- private function doAdditionalFailureDescription($other)
- {
- return '';
- }
- private function doCount()
- {
- return 1;
- }
- private function doEvaluate($other, $description, $returnResult)
- {
- $success = false;
- if ($this->matches($other)) {
- $success = true;
- }
- if ($returnResult) {
- return $success;
- }
- if (!$success) {
- $this->fail($other, $description);
- }
- return null;
- }
- private function doFailureDescription($other)
- {
- return $this->exporter()->export($other).' '.$this->toString();
- }
- private function doMatches($other)
- {
- return false;
- }
- private function doToString()
- {
- return '';
- }
- }
|