ConstraintLogicTrait.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bridge\PhpUnit\Legacy;
  11. /**
  12. * @internal
  13. */
  14. trait ConstraintLogicTrait
  15. {
  16. private function doEvaluate($other, $description, $returnResult)
  17. {
  18. $success = false;
  19. if ($this->matches($other)) {
  20. $success = true;
  21. }
  22. if ($returnResult) {
  23. return $success;
  24. }
  25. if (!$success) {
  26. $this->fail($other, $description);
  27. }
  28. return null;
  29. }
  30. private function doAdditionalFailureDescription($other): string
  31. {
  32. return '';
  33. }
  34. private function doCount(): int
  35. {
  36. return 1;
  37. }
  38. private function doFailureDescription($other): string
  39. {
  40. return $this->exporter()->export($other).' '.$this->toString();
  41. }
  42. private function doMatches($other): bool
  43. {
  44. return false;
  45. }
  46. private function doToString(): string
  47. {
  48. return '';
  49. }
  50. }