Conditions | 5 |
Paths | 5 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5 |
1 | <?php |
||
30 | 18 | public function validate($content, $file) |
|
31 | { |
||
32 | 18 | if (null === $content) { |
|
33 | 2 | return $content; |
|
34 | } |
||
35 | |||
36 | 16 | if (false === is_array($content)) { |
|
37 | 2 | throw new InvalidArgumentException( |
|
38 | 2 | sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file) |
|
39 | 1 | ); |
|
40 | } |
||
41 | |||
42 | 14 | foreach ($content as $namespace => $data) { |
|
43 | 14 | if (in_array($namespace, ['imports', 'parameters', 'services'])) { |
|
44 | 12 | continue; |
|
45 | } |
||
46 | |||
47 | 8 | throw new InvalidArgumentException( |
|
48 | 8 | sprintf('Invalid namespace name "%s" in "%s".', $namespace, $file) |
|
49 | 4 | ); |
|
50 | 3 | } |
|
51 | |||
52 | 6 | return $content; |
|
53 | } |
||
54 | } |
||
55 |