Total Complexity | 6 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 92.86% |
Changes | 0 |
1 | <?php |
||
6 | class ContainsOnlyAllowedMembersConstraint extends Constraint |
||
7 | { |
||
8 | /** |
||
9 | * @var array |
||
10 | */ |
||
11 | private $members; |
||
12 | |||
13 | 64 | public function __construct(array $members) |
|
14 | { |
||
15 | 64 | $this->members = $members; |
|
16 | 64 | } |
|
17 | |||
18 | /** |
||
19 | * Returns a string representation of the constraint. |
||
20 | */ |
||
21 | 14 | public function toString(): string |
|
22 | { |
||
23 | 14 | return \sprintf( |
|
24 | 14 | 'contains only elements of "%s"', |
|
25 | 14 | \implode(', ', $this->members) |
|
26 | ); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Evaluates the constraint for parameter $other. Returns true if the |
||
31 | * constraint is met, false otherwise. |
||
32 | * |
||
33 | * @param mixed $other value or object to evaluate |
||
34 | */ |
||
35 | 64 | protected function matches($other): bool |
|
48 | } |
||
49 | } |
||
50 |