@@ -14,75 +14,75 @@ |
||
14 | 14 | |
15 | 15 | class Attribute extends Composite |
16 | 16 | { |
17 | - /** |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $attributeName; |
|
17 | + /** |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $attributeName; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param Constraint $constraint |
|
24 | - * @param string $attributeName |
|
25 | - */ |
|
26 | - public function __construct(Constraint $constraint, $attributeName) |
|
27 | - { |
|
28 | - parent::__construct($constraint); |
|
22 | + /** |
|
23 | + * @param Constraint $constraint |
|
24 | + * @param string $attributeName |
|
25 | + */ |
|
26 | + public function __construct(Constraint $constraint, $attributeName) |
|
27 | + { |
|
28 | + parent::__construct($constraint); |
|
29 | 29 | |
30 | - $this->attributeName = $attributeName; |
|
31 | - } |
|
30 | + $this->attributeName = $attributeName; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Evaluates the constraint for parameter $other |
|
35 | - * |
|
36 | - * If $returnResult is set to false (the default), an exception is thrown |
|
37 | - * in case of a failure. null is returned otherwise. |
|
38 | - * |
|
39 | - * If $returnResult is true, the result of the evaluation is returned as |
|
40 | - * a boolean value instead: true in case of success, false in case of a |
|
41 | - * failure. |
|
42 | - * |
|
43 | - * @param mixed $other Value or object to evaluate. |
|
44 | - * @param string $description Additional information about the test |
|
45 | - * @param bool $returnResult Whether to return a result or throw an exception |
|
46 | - * |
|
47 | - * @return mixed |
|
48 | - * |
|
49 | - * @throws ExpectationFailedException |
|
50 | - */ |
|
51 | - public function evaluate($other, $description = '', $returnResult = false) |
|
52 | - { |
|
53 | - return parent::evaluate( |
|
54 | - Assert::readAttribute( |
|
55 | - $other, |
|
56 | - $this->attributeName |
|
57 | - ), |
|
58 | - $description, |
|
59 | - $returnResult |
|
60 | - ); |
|
61 | - } |
|
33 | + /** |
|
34 | + * Evaluates the constraint for parameter $other |
|
35 | + * |
|
36 | + * If $returnResult is set to false (the default), an exception is thrown |
|
37 | + * in case of a failure. null is returned otherwise. |
|
38 | + * |
|
39 | + * If $returnResult is true, the result of the evaluation is returned as |
|
40 | + * a boolean value instead: true in case of success, false in case of a |
|
41 | + * failure. |
|
42 | + * |
|
43 | + * @param mixed $other Value or object to evaluate. |
|
44 | + * @param string $description Additional information about the test |
|
45 | + * @param bool $returnResult Whether to return a result or throw an exception |
|
46 | + * |
|
47 | + * @return mixed |
|
48 | + * |
|
49 | + * @throws ExpectationFailedException |
|
50 | + */ |
|
51 | + public function evaluate($other, $description = '', $returnResult = false) |
|
52 | + { |
|
53 | + return parent::evaluate( |
|
54 | + Assert::readAttribute( |
|
55 | + $other, |
|
56 | + $this->attributeName |
|
57 | + ), |
|
58 | + $description, |
|
59 | + $returnResult |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Returns a string representation of the constraint. |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function toString() |
|
69 | - { |
|
70 | - return 'attribute "' . $this->attributeName . '" ' . |
|
71 | - $this->innerConstraint->toString(); |
|
72 | - } |
|
63 | + /** |
|
64 | + * Returns a string representation of the constraint. |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function toString() |
|
69 | + { |
|
70 | + return 'attribute "' . $this->attributeName . '" ' . |
|
71 | + $this->innerConstraint->toString(); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Returns the description of the failure |
|
76 | - * |
|
77 | - * The beginning of failure messages is "Failed asserting that" in most |
|
78 | - * cases. This method should return the second part of that sentence. |
|
79 | - * |
|
80 | - * @param mixed $other Evaluated value or object. |
|
81 | - * |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - protected function failureDescription($other) |
|
85 | - { |
|
86 | - return $this->toString(); |
|
87 | - } |
|
74 | + /** |
|
75 | + * Returns the description of the failure |
|
76 | + * |
|
77 | + * The beginning of failure messages is "Failed asserting that" in most |
|
78 | + * cases. This method should return the second part of that sentence. |
|
79 | + * |
|
80 | + * @param mixed $other Evaluated value or object. |
|
81 | + * |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + protected function failureDescription($other) |
|
85 | + { |
|
86 | + return $this->toString(); |
|
87 | + } |
|
88 | 88 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | */ |
68 | 68 | public function toString() |
69 | 69 | { |
70 | - return 'attribute "' . $this->attributeName . '" ' . |
|
70 | + return 'attribute "'.$this->attributeName.'" '. |
|
71 | 71 | $this->innerConstraint->toString(); |
72 | 72 | } |
73 | 73 |
@@ -16,107 +16,107 @@ |
||
16 | 16 | */ |
17 | 17 | class LogicalXor extends Constraint |
18 | 18 | { |
19 | - /** |
|
20 | - * @var Constraint[] |
|
21 | - */ |
|
22 | - protected $constraints = []; |
|
23 | - |
|
24 | - /** |
|
25 | - * @param Constraint[] $constraints |
|
26 | - */ |
|
27 | - public function setConstraints(array $constraints) |
|
28 | - { |
|
29 | - $this->constraints = []; |
|
30 | - |
|
31 | - foreach ($constraints as $constraint) { |
|
32 | - if (!($constraint instanceof Constraint)) { |
|
33 | - $constraint = new IsEqual( |
|
34 | - $constraint |
|
35 | - ); |
|
36 | - } |
|
37 | - |
|
38 | - $this->constraints[] = $constraint; |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Evaluates the constraint for parameter $other |
|
44 | - * |
|
45 | - * If $returnResult is set to false (the default), an exception is thrown |
|
46 | - * in case of a failure. null is returned otherwise. |
|
47 | - * |
|
48 | - * If $returnResult is true, the result of the evaluation is returned as |
|
49 | - * a boolean value instead: true in case of success, false in case of a |
|
50 | - * failure. |
|
51 | - * |
|
52 | - * @param mixed $other Value or object to evaluate. |
|
53 | - * @param string $description Additional information about the test |
|
54 | - * @param bool $returnResult Whether to return a result or throw an exception |
|
55 | - * |
|
56 | - * @return mixed |
|
57 | - * |
|
58 | - * @throws ExpectationFailedException |
|
59 | - */ |
|
60 | - public function evaluate($other, $description = '', $returnResult = false) |
|
61 | - { |
|
62 | - $success = true; |
|
63 | - $lastResult = null; |
|
64 | - $constraint = null; |
|
65 | - |
|
66 | - foreach ($this->constraints as $constraint) { |
|
67 | - $result = $constraint->evaluate($other, $description, true); |
|
68 | - |
|
69 | - if ($result === $lastResult) { |
|
70 | - $success = false; |
|
71 | - |
|
72 | - break; |
|
73 | - } |
|
74 | - |
|
75 | - $lastResult = $result; |
|
76 | - } |
|
77 | - |
|
78 | - if ($returnResult) { |
|
79 | - return $success; |
|
80 | - } |
|
81 | - |
|
82 | - if (!$success) { |
|
83 | - $this->fail($other, $description); |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Returns a string representation of the constraint. |
|
89 | - * |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function toString() |
|
93 | - { |
|
94 | - $text = ''; |
|
95 | - |
|
96 | - foreach ($this->constraints as $key => $constraint) { |
|
97 | - if ($key > 0) { |
|
98 | - $text .= ' xor '; |
|
99 | - } |
|
100 | - |
|
101 | - $text .= $constraint->toString(); |
|
102 | - } |
|
103 | - |
|
104 | - return $text; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Counts the number of constraint elements. |
|
109 | - * |
|
110 | - * @return int |
|
111 | - */ |
|
112 | - public function count() |
|
113 | - { |
|
114 | - $count = 0; |
|
115 | - |
|
116 | - foreach ($this->constraints as $constraint) { |
|
117 | - $count += \count($constraint); |
|
118 | - } |
|
119 | - |
|
120 | - return $count; |
|
121 | - } |
|
19 | + /** |
|
20 | + * @var Constraint[] |
|
21 | + */ |
|
22 | + protected $constraints = []; |
|
23 | + |
|
24 | + /** |
|
25 | + * @param Constraint[] $constraints |
|
26 | + */ |
|
27 | + public function setConstraints(array $constraints) |
|
28 | + { |
|
29 | + $this->constraints = []; |
|
30 | + |
|
31 | + foreach ($constraints as $constraint) { |
|
32 | + if (!($constraint instanceof Constraint)) { |
|
33 | + $constraint = new IsEqual( |
|
34 | + $constraint |
|
35 | + ); |
|
36 | + } |
|
37 | + |
|
38 | + $this->constraints[] = $constraint; |
|
39 | + } |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Evaluates the constraint for parameter $other |
|
44 | + * |
|
45 | + * If $returnResult is set to false (the default), an exception is thrown |
|
46 | + * in case of a failure. null is returned otherwise. |
|
47 | + * |
|
48 | + * If $returnResult is true, the result of the evaluation is returned as |
|
49 | + * a boolean value instead: true in case of success, false in case of a |
|
50 | + * failure. |
|
51 | + * |
|
52 | + * @param mixed $other Value or object to evaluate. |
|
53 | + * @param string $description Additional information about the test |
|
54 | + * @param bool $returnResult Whether to return a result or throw an exception |
|
55 | + * |
|
56 | + * @return mixed |
|
57 | + * |
|
58 | + * @throws ExpectationFailedException |
|
59 | + */ |
|
60 | + public function evaluate($other, $description = '', $returnResult = false) |
|
61 | + { |
|
62 | + $success = true; |
|
63 | + $lastResult = null; |
|
64 | + $constraint = null; |
|
65 | + |
|
66 | + foreach ($this->constraints as $constraint) { |
|
67 | + $result = $constraint->evaluate($other, $description, true); |
|
68 | + |
|
69 | + if ($result === $lastResult) { |
|
70 | + $success = false; |
|
71 | + |
|
72 | + break; |
|
73 | + } |
|
74 | + |
|
75 | + $lastResult = $result; |
|
76 | + } |
|
77 | + |
|
78 | + if ($returnResult) { |
|
79 | + return $success; |
|
80 | + } |
|
81 | + |
|
82 | + if (!$success) { |
|
83 | + $this->fail($other, $description); |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Returns a string representation of the constraint. |
|
89 | + * |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function toString() |
|
93 | + { |
|
94 | + $text = ''; |
|
95 | + |
|
96 | + foreach ($this->constraints as $key => $constraint) { |
|
97 | + if ($key > 0) { |
|
98 | + $text .= ' xor '; |
|
99 | + } |
|
100 | + |
|
101 | + $text .= $constraint->toString(); |
|
102 | + } |
|
103 | + |
|
104 | + return $text; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Counts the number of constraint elements. |
|
109 | + * |
|
110 | + * @return int |
|
111 | + */ |
|
112 | + public function count() |
|
113 | + { |
|
114 | + $count = 0; |
|
115 | + |
|
116 | + foreach ($this->constraints as $constraint) { |
|
117 | + $count += \count($constraint); |
|
118 | + } |
|
119 | + |
|
120 | + return $count; |
|
121 | + } |
|
122 | 122 | } |
@@ -20,77 +20,77 @@ |
||
20 | 20 | */ |
21 | 21 | class IsInstanceOf extends Constraint |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $className; |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $className; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param string $className |
|
30 | - */ |
|
31 | - public function __construct($className) |
|
32 | - { |
|
33 | - parent::__construct(); |
|
34 | - $this->className = $className; |
|
35 | - } |
|
28 | + /** |
|
29 | + * @param string $className |
|
30 | + */ |
|
31 | + public function __construct($className) |
|
32 | + { |
|
33 | + parent::__construct(); |
|
34 | + $this->className = $className; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
39 | - * constraint is met, false otherwise. |
|
40 | - * |
|
41 | - * @param mixed $other Value or object to evaluate. |
|
42 | - * |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - protected function matches($other) |
|
46 | - { |
|
47 | - return ($other instanceof $this->className); |
|
48 | - } |
|
37 | + /** |
|
38 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
39 | + * constraint is met, false otherwise. |
|
40 | + * |
|
41 | + * @param mixed $other Value or object to evaluate. |
|
42 | + * |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + protected function matches($other) |
|
46 | + { |
|
47 | + return ($other instanceof $this->className); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Returns the description of the failure |
|
52 | - * |
|
53 | - * The beginning of failure messages is "Failed asserting that" in most |
|
54 | - * cases. This method should return the second part of that sentence. |
|
55 | - * |
|
56 | - * @param mixed $other Evaluated value or object. |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - protected function failureDescription($other) |
|
61 | - { |
|
62 | - return \sprintf( |
|
63 | - '%s is an instance of %s "%s"', |
|
64 | - $this->exporter->shortenedExport($other), |
|
65 | - $this->getType(), |
|
66 | - $this->className |
|
67 | - ); |
|
68 | - } |
|
50 | + /** |
|
51 | + * Returns the description of the failure |
|
52 | + * |
|
53 | + * The beginning of failure messages is "Failed asserting that" in most |
|
54 | + * cases. This method should return the second part of that sentence. |
|
55 | + * |
|
56 | + * @param mixed $other Evaluated value or object. |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + protected function failureDescription($other) |
|
61 | + { |
|
62 | + return \sprintf( |
|
63 | + '%s is an instance of %s "%s"', |
|
64 | + $this->exporter->shortenedExport($other), |
|
65 | + $this->getType(), |
|
66 | + $this->className |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Returns a string representation of the constraint. |
|
72 | - * |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function toString() |
|
76 | - { |
|
77 | - return \sprintf( |
|
78 | - 'is instance of %s "%s"', |
|
79 | - $this->getType(), |
|
80 | - $this->className |
|
81 | - ); |
|
82 | - } |
|
70 | + /** |
|
71 | + * Returns a string representation of the constraint. |
|
72 | + * |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function toString() |
|
76 | + { |
|
77 | + return \sprintf( |
|
78 | + 'is instance of %s "%s"', |
|
79 | + $this->getType(), |
|
80 | + $this->className |
|
81 | + ); |
|
82 | + } |
|
83 | 83 | |
84 | - private function getType() |
|
85 | - { |
|
86 | - try { |
|
87 | - $reflection = new ReflectionClass($this->className); |
|
88 | - if ($reflection->isInterface()) { |
|
89 | - return 'interface'; |
|
90 | - } |
|
91 | - } catch (ReflectionException $e) { |
|
92 | - } |
|
84 | + private function getType() |
|
85 | + { |
|
86 | + try { |
|
87 | + $reflection = new ReflectionClass($this->className); |
|
88 | + if ($reflection->isInterface()) { |
|
89 | + return 'interface'; |
|
90 | + } |
|
91 | + } catch (ReflectionException $e) { |
|
92 | + } |
|
93 | 93 | |
94 | - return 'class'; |
|
95 | - } |
|
94 | + return 'class'; |
|
95 | + } |
|
96 | 96 | } |
@@ -16,102 +16,102 @@ |
||
16 | 16 | */ |
17 | 17 | class LogicalOr extends Constraint |
18 | 18 | { |
19 | - /** |
|
20 | - * @var Constraint[] |
|
21 | - */ |
|
22 | - protected $constraints = []; |
|
23 | - |
|
24 | - /** |
|
25 | - * @param Constraint[] $constraints |
|
26 | - */ |
|
27 | - public function setConstraints(array $constraints) |
|
28 | - { |
|
29 | - $this->constraints = []; |
|
30 | - |
|
31 | - foreach ($constraints as $constraint) { |
|
32 | - if (!($constraint instanceof Constraint)) { |
|
33 | - $constraint = new IsEqual( |
|
34 | - $constraint |
|
35 | - ); |
|
36 | - } |
|
37 | - |
|
38 | - $this->constraints[] = $constraint; |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Evaluates the constraint for parameter $other |
|
44 | - * |
|
45 | - * If $returnResult is set to false (the default), an exception is thrown |
|
46 | - * in case of a failure. null is returned otherwise. |
|
47 | - * |
|
48 | - * If $returnResult is true, the result of the evaluation is returned as |
|
49 | - * a boolean value instead: true in case of success, false in case of a |
|
50 | - * failure. |
|
51 | - * |
|
52 | - * @param mixed $other Value or object to evaluate. |
|
53 | - * @param string $description Additional information about the test |
|
54 | - * @param bool $returnResult Whether to return a result or throw an exception |
|
55 | - * |
|
56 | - * @return mixed |
|
57 | - * |
|
58 | - * @throws ExpectationFailedException |
|
59 | - */ |
|
60 | - public function evaluate($other, $description = '', $returnResult = false) |
|
61 | - { |
|
62 | - $success = false; |
|
63 | - $constraint = null; |
|
64 | - |
|
65 | - foreach ($this->constraints as $constraint) { |
|
66 | - if ($constraint->evaluate($other, $description, true)) { |
|
67 | - $success = true; |
|
68 | - |
|
69 | - break; |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - if ($returnResult) { |
|
74 | - return $success; |
|
75 | - } |
|
76 | - |
|
77 | - if (!$success) { |
|
78 | - $this->fail($other, $description); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Returns a string representation of the constraint. |
|
84 | - * |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - public function toString() |
|
88 | - { |
|
89 | - $text = ''; |
|
90 | - |
|
91 | - foreach ($this->constraints as $key => $constraint) { |
|
92 | - if ($key > 0) { |
|
93 | - $text .= ' or '; |
|
94 | - } |
|
95 | - |
|
96 | - $text .= $constraint->toString(); |
|
97 | - } |
|
98 | - |
|
99 | - return $text; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Counts the number of constraint elements. |
|
104 | - * |
|
105 | - * @return int |
|
106 | - */ |
|
107 | - public function count() |
|
108 | - { |
|
109 | - $count = 0; |
|
110 | - |
|
111 | - foreach ($this->constraints as $constraint) { |
|
112 | - $count += \count($constraint); |
|
113 | - } |
|
114 | - |
|
115 | - return $count; |
|
116 | - } |
|
19 | + /** |
|
20 | + * @var Constraint[] |
|
21 | + */ |
|
22 | + protected $constraints = []; |
|
23 | + |
|
24 | + /** |
|
25 | + * @param Constraint[] $constraints |
|
26 | + */ |
|
27 | + public function setConstraints(array $constraints) |
|
28 | + { |
|
29 | + $this->constraints = []; |
|
30 | + |
|
31 | + foreach ($constraints as $constraint) { |
|
32 | + if (!($constraint instanceof Constraint)) { |
|
33 | + $constraint = new IsEqual( |
|
34 | + $constraint |
|
35 | + ); |
|
36 | + } |
|
37 | + |
|
38 | + $this->constraints[] = $constraint; |
|
39 | + } |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Evaluates the constraint for parameter $other |
|
44 | + * |
|
45 | + * If $returnResult is set to false (the default), an exception is thrown |
|
46 | + * in case of a failure. null is returned otherwise. |
|
47 | + * |
|
48 | + * If $returnResult is true, the result of the evaluation is returned as |
|
49 | + * a boolean value instead: true in case of success, false in case of a |
|
50 | + * failure. |
|
51 | + * |
|
52 | + * @param mixed $other Value or object to evaluate. |
|
53 | + * @param string $description Additional information about the test |
|
54 | + * @param bool $returnResult Whether to return a result or throw an exception |
|
55 | + * |
|
56 | + * @return mixed |
|
57 | + * |
|
58 | + * @throws ExpectationFailedException |
|
59 | + */ |
|
60 | + public function evaluate($other, $description = '', $returnResult = false) |
|
61 | + { |
|
62 | + $success = false; |
|
63 | + $constraint = null; |
|
64 | + |
|
65 | + foreach ($this->constraints as $constraint) { |
|
66 | + if ($constraint->evaluate($other, $description, true)) { |
|
67 | + $success = true; |
|
68 | + |
|
69 | + break; |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + if ($returnResult) { |
|
74 | + return $success; |
|
75 | + } |
|
76 | + |
|
77 | + if (!$success) { |
|
78 | + $this->fail($other, $description); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Returns a string representation of the constraint. |
|
84 | + * |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + public function toString() |
|
88 | + { |
|
89 | + $text = ''; |
|
90 | + |
|
91 | + foreach ($this->constraints as $key => $constraint) { |
|
92 | + if ($key > 0) { |
|
93 | + $text .= ' or '; |
|
94 | + } |
|
95 | + |
|
96 | + $text .= $constraint->toString(); |
|
97 | + } |
|
98 | + |
|
99 | + return $text; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Counts the number of constraint elements. |
|
104 | + * |
|
105 | + * @return int |
|
106 | + */ |
|
107 | + public function count() |
|
108 | + { |
|
109 | + $count = 0; |
|
110 | + |
|
111 | + foreach ($this->constraints as $constraint) { |
|
112 | + $count += \count($constraint); |
|
113 | + } |
|
114 | + |
|
115 | + return $count; |
|
116 | + } |
|
117 | 117 | } |
@@ -14,26 +14,26 @@ |
||
14 | 14 | */ |
15 | 15 | class IsNull extends Constraint |
16 | 16 | { |
17 | - /** |
|
18 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
19 | - * constraint is met, false otherwise. |
|
20 | - * |
|
21 | - * @param mixed $other Value or object to evaluate. |
|
22 | - * |
|
23 | - * @return bool |
|
24 | - */ |
|
25 | - protected function matches($other) |
|
26 | - { |
|
27 | - return $other === null; |
|
28 | - } |
|
17 | + /** |
|
18 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
19 | + * constraint is met, false otherwise. |
|
20 | + * |
|
21 | + * @param mixed $other Value or object to evaluate. |
|
22 | + * |
|
23 | + * @return bool |
|
24 | + */ |
|
25 | + protected function matches($other) |
|
26 | + { |
|
27 | + return $other === null; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Returns a string representation of the constraint. |
|
32 | - * |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function toString() |
|
36 | - { |
|
37 | - return 'is null'; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Returns a string representation of the constraint. |
|
32 | + * |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function toString() |
|
36 | + { |
|
37 | + return 'is null'; |
|
38 | + } |
|
39 | 39 | } |
@@ -15,41 +15,41 @@ |
||
15 | 15 | */ |
16 | 16 | class GreaterThan extends Constraint |
17 | 17 | { |
18 | - /** |
|
19 | - * @var int|float |
|
20 | - */ |
|
21 | - protected $value; |
|
18 | + /** |
|
19 | + * @var int|float |
|
20 | + */ |
|
21 | + protected $value; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @param int|float $value |
|
25 | - */ |
|
26 | - public function __construct($value) |
|
27 | - { |
|
28 | - parent::__construct(); |
|
23 | + /** |
|
24 | + * @param int|float $value |
|
25 | + */ |
|
26 | + public function __construct($value) |
|
27 | + { |
|
28 | + parent::__construct(); |
|
29 | 29 | |
30 | - $this->value = $value; |
|
31 | - } |
|
30 | + $this->value = $value; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
35 | - * constraint is met, false otherwise. |
|
36 | - * |
|
37 | - * @param mixed $other Value or object to evaluate. |
|
38 | - * |
|
39 | - * @return bool |
|
40 | - */ |
|
41 | - protected function matches($other) |
|
42 | - { |
|
43 | - return $this->value < $other; |
|
44 | - } |
|
33 | + /** |
|
34 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
35 | + * constraint is met, false otherwise. |
|
36 | + * |
|
37 | + * @param mixed $other Value or object to evaluate. |
|
38 | + * |
|
39 | + * @return bool |
|
40 | + */ |
|
41 | + protected function matches($other) |
|
42 | + { |
|
43 | + return $this->value < $other; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Returns a string representation of the constraint. |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function toString() |
|
52 | - { |
|
53 | - return 'is greater than ' . $this->exporter->export($this->value); |
|
54 | - } |
|
46 | + /** |
|
47 | + * Returns a string representation of the constraint. |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function toString() |
|
52 | + { |
|
53 | + return 'is greater than ' . $this->exporter->export($this->value); |
|
54 | + } |
|
55 | 55 | } |
@@ -50,6 +50,6 @@ |
||
50 | 50 | */ |
51 | 51 | public function toString() |
52 | 52 | { |
53 | - return 'is greater than ' . $this->exporter->export($this->value); |
|
53 | + return 'is greater than '.$this->exporter->export($this->value); |
|
54 | 54 | } |
55 | 55 | } |
@@ -15,41 +15,41 @@ |
||
15 | 15 | */ |
16 | 16 | class LessThan extends Constraint |
17 | 17 | { |
18 | - /** |
|
19 | - * @var int|float |
|
20 | - */ |
|
21 | - protected $value; |
|
18 | + /** |
|
19 | + * @var int|float |
|
20 | + */ |
|
21 | + protected $value; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @param int|float $value |
|
25 | - */ |
|
26 | - public function __construct($value) |
|
27 | - { |
|
28 | - parent::__construct(); |
|
23 | + /** |
|
24 | + * @param int|float $value |
|
25 | + */ |
|
26 | + public function __construct($value) |
|
27 | + { |
|
28 | + parent::__construct(); |
|
29 | 29 | |
30 | - $this->value = $value; |
|
31 | - } |
|
30 | + $this->value = $value; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
35 | - * constraint is met, false otherwise. |
|
36 | - * |
|
37 | - * @param mixed $other Value or object to evaluate. |
|
38 | - * |
|
39 | - * @return bool |
|
40 | - */ |
|
41 | - protected function matches($other) |
|
42 | - { |
|
43 | - return $this->value > $other; |
|
44 | - } |
|
33 | + /** |
|
34 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
35 | + * constraint is met, false otherwise. |
|
36 | + * |
|
37 | + * @param mixed $other Value or object to evaluate. |
|
38 | + * |
|
39 | + * @return bool |
|
40 | + */ |
|
41 | + protected function matches($other) |
|
42 | + { |
|
43 | + return $this->value > $other; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Returns a string representation of the constraint. |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function toString() |
|
52 | - { |
|
53 | - return 'is less than ' . $this->exporter->export($this->value); |
|
54 | - } |
|
46 | + /** |
|
47 | + * Returns a string representation of the constraint. |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function toString() |
|
52 | + { |
|
53 | + return 'is less than ' . $this->exporter->export($this->value); |
|
54 | + } |
|
55 | 55 | } |
@@ -50,6 +50,6 @@ |
||
50 | 50 | */ |
51 | 51 | public function toString() |
52 | 52 | { |
53 | - return 'is less than ' . $this->exporter->export($this->value); |
|
53 | + return 'is less than '.$this->exporter->export($this->value); |
|
54 | 54 | } |
55 | 55 | } |
@@ -14,76 +14,76 @@ |
||
14 | 14 | |
15 | 15 | class Exception extends Constraint |
16 | 16 | { |
17 | - /** |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $className; |
|
17 | + /** |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $className; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param string $className |
|
24 | - */ |
|
25 | - public function __construct($className) |
|
26 | - { |
|
27 | - parent::__construct(); |
|
28 | - $this->className = $className; |
|
29 | - } |
|
22 | + /** |
|
23 | + * @param string $className |
|
24 | + */ |
|
25 | + public function __construct($className) |
|
26 | + { |
|
27 | + parent::__construct(); |
|
28 | + $this->className = $className; |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
33 | - * constraint is met, false otherwise. |
|
34 | - * |
|
35 | - * @param mixed $other Value or object to evaluate. |
|
36 | - * |
|
37 | - * @return bool |
|
38 | - */ |
|
39 | - protected function matches($other) |
|
40 | - { |
|
41 | - return $other instanceof $this->className; |
|
42 | - } |
|
31 | + /** |
|
32 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
33 | + * constraint is met, false otherwise. |
|
34 | + * |
|
35 | + * @param mixed $other Value or object to evaluate. |
|
36 | + * |
|
37 | + * @return bool |
|
38 | + */ |
|
39 | + protected function matches($other) |
|
40 | + { |
|
41 | + return $other instanceof $this->className; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Returns the description of the failure |
|
46 | - * |
|
47 | - * The beginning of failure messages is "Failed asserting that" in most |
|
48 | - * cases. This method should return the second part of that sentence. |
|
49 | - * |
|
50 | - * @param mixed $other Evaluated value or object. |
|
51 | - * |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - protected function failureDescription($other) |
|
55 | - { |
|
56 | - if ($other !== null) { |
|
57 | - $message = ''; |
|
58 | - if ($other instanceof Throwable) { |
|
59 | - $message = '. Message was: "' . $other->getMessage() . '" at' |
|
60 | - . "\n" . Filter::getFilteredStacktrace($other); |
|
61 | - } |
|
44 | + /** |
|
45 | + * Returns the description of the failure |
|
46 | + * |
|
47 | + * The beginning of failure messages is "Failed asserting that" in most |
|
48 | + * cases. This method should return the second part of that sentence. |
|
49 | + * |
|
50 | + * @param mixed $other Evaluated value or object. |
|
51 | + * |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + protected function failureDescription($other) |
|
55 | + { |
|
56 | + if ($other !== null) { |
|
57 | + $message = ''; |
|
58 | + if ($other instanceof Throwable) { |
|
59 | + $message = '. Message was: "' . $other->getMessage() . '" at' |
|
60 | + . "\n" . Filter::getFilteredStacktrace($other); |
|
61 | + } |
|
62 | 62 | |
63 | - return \sprintf( |
|
64 | - 'exception of type "%s" matches expected exception "%s"%s', |
|
65 | - \get_class($other), |
|
66 | - $this->className, |
|
67 | - $message |
|
68 | - ); |
|
69 | - } |
|
63 | + return \sprintf( |
|
64 | + 'exception of type "%s" matches expected exception "%s"%s', |
|
65 | + \get_class($other), |
|
66 | + $this->className, |
|
67 | + $message |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | |
71 | - return \sprintf( |
|
72 | - 'exception of type "%s" is thrown', |
|
73 | - $this->className |
|
74 | - ); |
|
75 | - } |
|
71 | + return \sprintf( |
|
72 | + 'exception of type "%s" is thrown', |
|
73 | + $this->className |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Returns a string representation of the constraint. |
|
79 | - * |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function toString() |
|
83 | - { |
|
84 | - return \sprintf( |
|
85 | - 'exception of type "%s"', |
|
86 | - $this->className |
|
87 | - ); |
|
88 | - } |
|
77 | + /** |
|
78 | + * Returns a string representation of the constraint. |
|
79 | + * |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function toString() |
|
83 | + { |
|
84 | + return \sprintf( |
|
85 | + 'exception of type "%s"', |
|
86 | + $this->className |
|
87 | + ); |
|
88 | + } |
|
89 | 89 | } |
@@ -56,8 +56,8 @@ |
||
56 | 56 | if ($other !== null) { |
57 | 57 | $message = ''; |
58 | 58 | if ($other instanceof Throwable) { |
59 | - $message = '. Message was: "' . $other->getMessage() . '" at' |
|
60 | - . "\n" . Filter::getFilteredStacktrace($other); |
|
59 | + $message = '. Message was: "'.$other->getMessage().'" at' |
|
60 | + . "\n".Filter::getFilteredStacktrace($other); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | return \sprintf( |
@@ -15,40 +15,40 @@ |
||
15 | 15 | */ |
16 | 16 | class StringStartsWith extends Constraint |
17 | 17 | { |
18 | - /** |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - protected $prefix; |
|
18 | + /** |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + protected $prefix; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @param string $prefix |
|
25 | - */ |
|
26 | - public function __construct($prefix) |
|
27 | - { |
|
28 | - parent::__construct(); |
|
29 | - $this->prefix = $prefix; |
|
30 | - } |
|
23 | + /** |
|
24 | + * @param string $prefix |
|
25 | + */ |
|
26 | + public function __construct($prefix) |
|
27 | + { |
|
28 | + parent::__construct(); |
|
29 | + $this->prefix = $prefix; |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Evaluates the constraint for parameter $other. Returns true if the |
|
34 | - * constraint is met, false otherwise. |
|
35 | - * |
|
36 | - * @param mixed $other Value or object to evaluate. |
|
37 | - * |
|
38 | - * @return bool |
|
39 | - */ |
|
40 | - protected function matches($other) |
|
41 | - { |
|
42 | - return \strpos($other, $this->prefix) === 0; |
|
43 | - } |
|
32 | + /** |
|
33 | + * Evaluates the constraint for parameter $other. Returns true if the |
|
34 | + * constraint is met, false otherwise. |
|
35 | + * |
|
36 | + * @param mixed $other Value or object to evaluate. |
|
37 | + * |
|
38 | + * @return bool |
|
39 | + */ |
|
40 | + protected function matches($other) |
|
41 | + { |
|
42 | + return \strpos($other, $this->prefix) === 0; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Returns a string representation of the constraint. |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function toString() |
|
51 | - { |
|
52 | - return 'starts with "' . $this->prefix . '"'; |
|
53 | - } |
|
45 | + /** |
|
46 | + * Returns a string representation of the constraint. |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function toString() |
|
51 | + { |
|
52 | + return 'starts with "' . $this->prefix . '"'; |
|
53 | + } |
|
54 | 54 | } |
@@ -49,6 +49,6 @@ |
||
49 | 49 | */ |
50 | 50 | public function toString() |
51 | 51 | { |
52 | - return 'starts with "' . $this->prefix . '"'; |
|
52 | + return 'starts with "'.$this->prefix.'"'; |
|
53 | 53 | } |
54 | 54 | } |