Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Lines | 17 |
Ratio | 100 % |
Tests | 6 |
CRAP Score | 3.576 |
Changes | 0 |
1 | <?php |
||
21 | 2 | public function hydrate($object, $source, DocumentHydrator $hydrator) |
|
22 | { |
||
23 | 2 | if (! $object instanceof IncludedResourcesAwareInterface) { |
|
24 | throw new InvalidDocumentException(sprintf( |
||
25 | 'Given instance of "%s" does not implements "%s"', |
||
26 | get_class($object), |
||
27 | IncludedResourcesAwareInterface::class |
||
28 | )); |
||
29 | } |
||
30 | |||
31 | 2 | foreach ($source as $item) |
|
32 | { |
||
33 | 1 | $resource = $hydrator->hydrateResource($item); |
|
34 | |||
35 | 1 | $object->addIncludedResource($resource); |
|
36 | } |
||
37 | 2 | } |
|
38 | |||
46 | } |
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.