Conditions | 8 |
Paths | 8 |
Total Lines | 25 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | public function normalizeDeclaration($declaration) |
||
8 | { |
||
9 | if (is_string($declaration)) { |
||
10 | return $this->normalizeString($declaration); |
||
11 | } |
||
12 | |||
13 | if (array_keys($declaration) === array_keys(array_values($declaration))) { |
||
14 | if (false === strpos($declaration[0], ':')) { |
||
15 | throw new \RuntimeException('The first argument for a resource configuration, when expressed with a numerically indexed array, should be a string containing the service and the method used, seperated by a colon.'); |
||
|
|||
16 | } elseif (isset($declaration[1]) && !is_array($declaration[1])) { |
||
17 | throw new \RuntimeException('The second argument for a resource configuration, when expressed with a numerically indexed array, should be an array of arguments.'); |
||
18 | } |
||
19 | |||
20 | list($service, $method) = explode(':', $declaration[0]); |
||
21 | |||
22 | return [ |
||
23 | 'service' => $service, |
||
24 | 'method' => $method, |
||
25 | 'arguments' => isset($declaration[1]) ? $declaration[1] : [], |
||
26 | 'required' => isset($declaration[2]) ? (bool) $declaration[2] : true, |
||
27 | ]; |
||
28 | } |
||
29 | |||
30 | return array_merge(['required' => true, 'arguments' => []], $declaration); |
||
31 | } |
||
32 | |||
50 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.