| Conditions | 6 |
| Paths | 1 |
| Total Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 30 |
| CRAP Score | 6.0087 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 2 | public function getConfigTreeBuilder() |
|
| 19 | { |
||
| 20 | 2 | $treeBuilder = new TreeBuilder('happyr_blaze'); |
|
| 21 | 2 | $rootNode = $treeBuilder->getRootNode(); |
|
| 22 | |||
| 23 | 2 | $rootNode->children() |
|
| 24 | 2 | ->arrayNode('objects') |
|
| 25 | 2 | ->requiresAtLeastOneElement() |
|
| 26 | 2 | ->useAttributeAsKey('name') |
|
| 27 | 2 | ->prototype('variable') |
|
| 28 | 2 | ->treatNullLike([]) |
|
| 29 | |||
| 30 | //make sure that there is some config after each object |
||
| 31 | 2 | ->validate() |
|
| 32 | 2 | ->ifTrue( |
|
| 33 | 2 | function ($objects) { |
|
| 34 | 1 | foreach ($objects as $o) { |
|
| 35 | 1 | if (!is_array($o)) { |
|
| 36 | return true; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | 1 | return false; |
|
| 41 | 2 | } |
|
| 42 | ) |
||
| 43 | 2 | ->thenInvalid('The happyr_blaze.objects config %s must be an array.') |
|
| 44 | 2 | ->end() |
|
| 45 | |||
| 46 | //make sure route and parameters is set |
||
| 47 | 2 | ->validate() |
|
| 48 | 2 | ->ifTrue( |
|
| 49 | 2 | function ($objects) { |
|
| 50 | 1 | foreach ($objects as $o) { |
|
| 51 | 1 | if (!isset($o['route']) || !isset($o['parameters'])) { |
|
| 52 | return true; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | 1 | return false; |
|
| 57 | 2 | } |
|
| 58 | ) |
||
| 59 | 2 | ->thenInvalid('%s must contain "route" and "parameters".') |
|
| 60 | 2 | ->end() |
|
| 61 | 2 | ->end() |
|
| 62 | 2 | ->end(); |
|
| 63 | |||
| 64 | 2 | return $treeBuilder; |
|
| 65 | } |
||
| 66 | } |
||
| 67 |