Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 12 |
Ratio | 100 % |
1 | <?php |
||
14 | public static function fromArray(array $events = []): EventRecordCollection |
||
15 | { |
||
16 | $indexed = []; |
||
17 | foreach ($events as $event) { |
||
18 | if (!$event instanceof EventRecord) { |
||
19 | throw new \InvalidArgumentException(sprintf('Invalid EventRecord, got: %s', get_class($event))); |
||
20 | } |
||
21 | $indexed[] = $event; |
||
22 | } |
||
23 | |||
24 | return new self(new \ArrayIterator($indexed)); |
||
25 | } |
||
26 | |||
39 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.