| Conditions | 4 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public static function createSitemapItemFromPostValues($postValues) |
||
| 24 | { |
||
| 25 | if (isset($postValues['title'], $postValues['url'], $postValues['component'], $postValues['template'])) { |
||
| 26 | $sitemapObject = new \stdClass(); |
||
| 27 | $sitemapObject->title = $postValues['title']; |
||
| 28 | $sitemapObject->slug = StringUtil::slugify($postValues['title']); |
||
| 29 | $sitemapObject->url = $postValues['url']; |
||
| 30 | $sitemapObject->component = $postValues['component']; |
||
| 31 | $sitemapObject->template = $postValues['template']; |
||
| 32 | $sitemapObject->regex = isset($postValues['regex']); |
||
| 33 | $sitemapObject->parameters = new \stdClass(); |
||
| 34 | if (isset($postValues['parameterNames'], $postValues['parameterValues'])) { |
||
| 35 | foreach ($postValues['parameterNames'] as $key => $value) { |
||
| 36 | $sitemapObject->parameters->$value = $postValues['parameterValues'][$key]; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | return $sitemapObject; |
||
| 41 | } else { |
||
| 42 | throw new \Exception('Trying to create sitemap item with invalid data.'); |
||
| 43 | } |
||
| 45 | } |