| Conditions | 4 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| 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 | 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 | } |
||
| 40 | } |