Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Lines | 6 |
Ratio | 31.58 % |
Tests | 6 |
CRAP Score | 4.5923 |
Changes | 0 |
1 | <?php |
||
19 | 1 | public function generateRoutes(array $routes) |
|
20 | { |
||
21 | 1 | $ret = []; |
|
22 | |||
23 | 1 | if (!method_exists($this->routerHelper, 'path')) { |
|
24 | // symfony 2.7 and lower don't have the path method, BC layer |
||
25 | 1 | View Code Duplication | foreach ($routes as $route => $params) { |
|
|||
26 | 1 | $ret[] = sprintf('api.%s = "%s";', $route, $this->routerHelper->generate($route, $params)); |
|
27 | } |
||
28 | |||
29 | 1 | return $ret; |
|
30 | } |
||
31 | |||
32 | View Code Duplication | foreach ($routes as $route => $params) { |
|
33 | $ret[] = sprintf('api.%s = "%s";', $route, $this->routerHelper->path($route, $params)); |
||
34 | } |
||
35 | |||
36 | return $ret; |
||
37 | } |
||
38 | |||
82 |
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.