Conditions | 3 |
Paths | 1 |
Total Lines | 68 |
Code Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php declare(strict_types=1); |
||
13 | public function getConfigTreeBuilder(): TreeBuilder |
||
14 | { |
||
15 | $treeBuilder = new TreeBuilder('entity_change_watch'); |
||
16 | |||
17 | $rootNode = $treeBuilder->getRootNode(); |
||
18 | |||
19 | $rootNode->children() |
||
20 | ->arrayNode('classes')->validate()->ifTrue(function ($classes) { |
||
21 | |||
22 | foreach ($classes as $key => $value) { |
||
23 | if (!class_exists($key)) { |
||
24 | return $key; |
||
25 | } |
||
26 | } |
||
27 | |||
28 | return false; |
||
29 | })->thenInvalid('Class not found')->end() |
||
30 | ->prototype('array') |
||
31 | ->children() |
||
32 | ->arrayNode('update') |
||
33 | ->children() |
||
34 | ->arrayNode('all') |
||
35 | ->prototype('array') |
||
36 | ->children() |
||
37 | ->scalarNode('name')->end() |
||
38 | ->scalarNode('method')->end() |
||
39 | ->scalarNode('flush')->defaultTrue()->end() |
||
40 | ->end() |
||
41 | ->end() |
||
42 | ->end() |
||
43 | ->arrayNode('properties') |
||
44 | ->prototype('array') |
||
45 | ->prototype('array') |
||
46 | ->children() |
||
47 | ->scalarNode('name')->end() |
||
48 | ->scalarNode('method')->end() |
||
49 | ->scalarNode('flush')->defaultTrue()->end() |
||
50 | ->end() |
||
51 | ->end() |
||
52 | ->end() |
||
53 | ->end() |
||
54 | ->end() |
||
55 | ->end() |
||
56 | ->arrayNode('create') |
||
57 | ->prototype('array') |
||
58 | ->children() |
||
59 | ->scalarNode('name')->end() |
||
60 | ->scalarNode('method')->end() |
||
61 | ->scalarNode('flush')->defaultTrue()->end() |
||
62 | ->end() |
||
63 | ->end() |
||
64 | ->end() |
||
65 | ->arrayNode('delete') |
||
66 | ->prototype('array') |
||
67 | ->children() |
||
68 | ->scalarNode('name')->end() |
||
69 | ->scalarNode('method')->end() |
||
70 | ->scalarNode('flush')->defaultTrue()->end() |
||
71 | ->end() |
||
72 | ->end() |
||
73 | ->end() |
||
74 | ->end() |
||
75 | ->end() |
||
76 | ->end() |
||
77 | ->end() |
||
78 | ; |
||
79 | |||
80 | return $treeBuilder; |
||
81 | } |
||
83 |