| Total Complexity | 6 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class ContainsOnlyAllowedMembersConstraint extends Constraint |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var array<string> |
||
| 15 | */ |
||
| 16 | private $members; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Class constructor. |
||
| 20 | * |
||
| 21 | * @param array<string> $members |
||
| 22 | */ |
||
| 23 | 107 | public function __construct(array $members) |
|
| 26 | 107 | } |
|
| 27 | |||
| 28 | /** |
||
| 29 | * Returns a string representation of the constraint. |
||
| 30 | */ |
||
| 31 | 26 | public function toString(): string |
|
| 32 | { |
||
| 33 | 26 | return \sprintf( |
|
| 34 | 26 | 'contains only elements of "%s"', |
|
| 35 | 26 | \implode(', ', $this->members) |
|
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Evaluates the constraint for parameter $other. Returns true if the |
||
| 41 | * constraint is met, false otherwise. |
||
| 42 | * |
||
| 43 | * @param mixed $other value or object to evaluate |
||
| 44 | */ |
||
| 45 | 107 | protected function matches($other): bool |
|
| 58 | } |
||
| 59 | } |
||
| 60 |