Conditions | 4 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 13 |
Lines | 5 |
Ratio | 26.32 % |
Changes | 0 |
1 | <?php |
||
21 | public static function createApplicationComponentFromPostValues($postValues) |
||
22 | { |
||
23 | if (isset($postValues['title'], $postValues['component'])) { |
||
24 | $applicationComponent = new \stdClass(); |
||
25 | $applicationComponent->title = $postValues['title']; |
||
26 | $applicationComponent->slug = StringUtil::slugify($postValues['title']); |
||
27 | $applicationComponent->component = $postValues['component']; |
||
28 | $applicationComponent->parameters = new \stdClass(); |
||
29 | View Code Duplication | if (isset($postValues['parameterNames'], $postValues['parameterValues'])) { |
|
|
|||
30 | foreach ($postValues['parameterNames'] as $key => $value) { |
||
31 | $applicationComponent->parameters->$value = $postValues['parameterValues'][$key]; |
||
32 | } |
||
33 | } |
||
34 | |||
35 | return $applicationComponent; |
||
36 | } else { |
||
37 | throw new \Exception('Trying to create application component with invalid data.'); |
||
38 | } |
||
39 | } |
||
40 | } |
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.