| Conditions | 8 |
| Paths | 36 |
| Total Lines | 33 |
| Code Lines | 21 |
| Lines | 8 |
| Ratio | 24.24 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 10 | public function process(ContainerBuilder $container) |
||
| 11 | { |
||
| 12 | $viewReferenceManagers = $container->findTaggedServiceIds( |
||
| 13 | 'view_reference.manager' |
||
| 14 | ); |
||
| 15 | |||
| 16 | $viewReferenceRepositories = $container->findTaggedServiceIds( |
||
| 17 | 'view_reference.repository' |
||
| 18 | ); |
||
| 19 | $connectors = []; |
||
| 20 | $connectorType = $container->getParameter('victoire_view_reference.connector.type'); |
||
| 21 | foreach ($viewReferenceManagers as $id => $tags) { |
||
| 22 | foreach ($tags as $attributes) { |
||
| 23 | $connectors[$attributes['connector']]['manager'] = $id; |
||
| 24 | } |
||
| 25 | } |
||
| 26 | foreach ($viewReferenceRepositories as $id => $tags) { |
||
| 27 | foreach ($tags as $attributes) { |
||
| 28 | $connectors[$attributes['connector']]['repository'] = $id; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | if (!isset($connectorType)) { |
||
| 32 | throw new \Exception('No manager and repository found to have '.$connectorType.' connector.'); |
||
| 33 | } |
||
| 34 | View Code Duplication | if (!isset($connectors[$connectorType]['manager'])) { |
|
|
|
|||
| 35 | throw new \Exception('No manager found to have '.$connectorType.' connector.'); |
||
| 36 | } |
||
| 37 | View Code Duplication | if (!isset($connectors[$connectorType]['repository'])) { |
|
| 38 | throw new \Exception('No repository found to have '.$connectorType.' connector.'); |
||
| 39 | } |
||
| 40 | $container->setAlias('victoire_view_reference.connector.manager', $connectors[$connectorType]['manager']); |
||
| 41 | $container->setAlias('victoire_view_reference.connector.repository', $connectors[$connectorType]['repository']); |
||
| 42 | } |
||
| 43 | } |
||
| 44 |
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.