Conditions | 4 |
Paths | 3 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function getParameters($permalink) |
||
28 | { |
||
29 | $parameters = explode('/', $permalink); |
||
30 | |||
31 | if (\count($parameters) > 2 || 0 === \count($parameters)) { |
||
32 | throw new \InvalidArgumentException('wrong permalink format'); |
||
33 | } |
||
34 | |||
35 | if (false === strpos($permalink, '/')) { |
||
36 | $collection = null; |
||
37 | $slug = $permalink; |
||
38 | } else { |
||
39 | list($collection, $slug) = $parameters; |
||
40 | } |
||
41 | |||
42 | return [ |
||
43 | 'collection' => $collection, |
||
44 | 'slug' => $slug, |
||
45 | ]; |
||
46 | } |
||
47 | } |
||
48 |