| Total Complexity | 3 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 40% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | final class IsOneOfAssert extends Constraint |
||
| 18 | { |
||
| 19 | private array $allowedValues; |
||
| 20 | |||
| 21 | 8 | public function __construct(array $allowedValues) |
|
| 22 | { |
||
| 23 | 8 | $this->allowedValues = $allowedValues; |
|
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Returns a string representation of the object. |
||
| 28 | * |
||
| 29 | * @return string |
||
| 30 | */ |
||
| 31 | public function toString(): string |
||
| 32 | { |
||
| 33 | $allowedValues = array_map(static function ($value) { |
||
| 34 | return VarDumper::create($value)->asString(); |
||
| 35 | }, $this->allowedValues); |
||
| 36 | |||
| 37 | $expectedAsString = implode(', ', $allowedValues); |
||
| 38 | |||
| 39 | return "is one of $expectedAsString"; |
||
| 40 | } |
||
| 41 | |||
| 42 | 8 | protected function matches($other): bool |
|
| 45 | } |
||
| 46 | } |
||
| 47 |