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