| Conditions | 5 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | protected function assertContainsInstanceOf(string $expected, $collection): void |
||
| 41 | { |
||
| 42 | if (!is_array($collection) && !($collection instanceof Traversable)) { |
||
| 43 | throw new InvalidArgumentException('The collection is neither an array nor traversable'); |
||
| 44 | } |
||
| 45 | |||
| 46 | $containsInstanceOf = false; |
||
| 47 | |||
| 48 | foreach ($collection as $element) { |
||
| 49 | if ($element instanceof $expected) { |
||
| 50 | $containsInstanceOf = true; |
||
| 51 | |||
| 52 | break; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | $this->assertTrue($containsInstanceOf, "The collection does not contain an instance of `{$expected}`"); |
||
| 57 | } |
||
| 59 |