Conditions | 2 |
Paths | 1 |
Total Lines | 48 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Tests | 41 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
37 | 7 | public function getConfigTreeBuilder() |
|
38 | { |
||
39 | 7 | $treeBuilder = new TreeBuilder(); |
|
40 | 7 | $rootNode = $treeBuilder->root($this->alias); |
|
41 | $rootNode |
||
42 | 7 | ->validate() |
|
43 | ->ifTrue(function($v) { |
||
44 | 7 | return !empty($v['enabled']) && empty($v['pools']); |
|
45 | 7 | }) |
|
46 | 7 | ->thenInvalid('The child node "pools" at path "'.$this->alias.'" must be configured.') |
|
47 | 7 | ->end() |
|
48 | 7 | ->children() |
|
49 | 7 | ->scalarNode('enabled') |
|
50 | 7 | ->defaultTrue() |
|
51 | 7 | ->end() |
|
52 | 7 | ->arrayNode('pools') |
|
53 | 7 | ->requiresAtLeastOneElement() |
|
54 | 7 | ->validate() |
|
55 | ->ifTrue(function (array $value) { |
||
56 | 5 | return !array_key_exists('default', $value); |
|
57 | 7 | }) |
|
58 | 7 | ->thenInvalid('Default service not present') |
|
59 | 7 | ->end() |
|
60 | 7 | ->prototype('array') |
|
61 | 7 | ->children() |
|
62 | 7 | ->scalarNode('send_driver') |
|
63 | 7 | ->isRequired() |
|
64 | 7 | ->validate() |
|
65 | 7 | ->ifTrue(function ($value) { |
|
66 | 5 | return !preg_match('/^@[a-zA-Z\.\-0-9\_]+$/', $value); |
|
67 | 7 | }) |
|
68 | 7 | ->thenInvalid('Malformed service ID "%s"') |
|
69 | 7 | ->end() |
|
70 | 7 | ->end() |
|
71 | 7 | ->end() |
|
72 | 7 | ->end() |
|
73 | 7 | ->end() |
|
74 | 7 | ->arrayNode('routes') |
|
75 | 7 | ->normalizeKeys(false) |
|
76 | 7 | ->prototype('scalar') |
|
77 | 7 | ->isRequired() |
|
78 | 7 | ->end() |
|
79 | 7 | ->end() |
|
80 | 7 | ->end() |
|
81 | ; |
||
82 | |||
83 | 7 | return $treeBuilder; |
|
84 | } |
||
85 | } |
||
86 |