Total Complexity | 6 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | trait HandlesParameters |
||
6 | { |
||
7 | public function parameterNames() |
||
8 | { |
||
9 | preg_match_all('/\{(.*?)\}/', $this->pattern, $matches); |
||
10 | |||
11 | return array_map(function ($m) { |
||
12 | return trim($m, '?'); |
||
13 | }, $matches[1]); |
||
14 | } |
||
15 | |||
16 | public function parameters() |
||
17 | { |
||
18 | return $this->matchToKeys(array_slice($this->matches, 1)); |
||
19 | } |
||
20 | |||
21 | public function parametersWithoutNulls() |
||
22 | { |
||
23 | return array_filter($this->parameters(), function ($p) { |
||
24 | return ! is_null($p); |
||
25 | }); |
||
26 | } |
||
27 | |||
28 | protected function matchToKeys(array $matches) |
||
38 | }); |
||
39 | } |
||
40 | } |
||
41 |