Conditions | 5 |
Paths | 2 |
Total Lines | 52 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
33 | public function getConfigTreeBuilder() |
||
34 | { |
||
35 | $treeBuilder = new TreeBuilder('pomm'); |
||
36 | $rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('pomm'); |
||
|
|||
37 | |||
38 | $rootNode |
||
39 | ->children() |
||
40 | ->arrayNode('configuration') |
||
41 | ->useAttributeAsKey('key') |
||
42 | ->requiresAtLeastOneElement() |
||
43 | ->prototype('array') |
||
44 | ->children() |
||
45 | ->scalarNode('dsn')->isRequired()->end() |
||
46 | ->scalarNode('class:session_builder') |
||
47 | ->defaultNull() |
||
48 | ->beforeNormalization() |
||
49 | ->always() |
||
50 | ->then(function ($v) { |
||
51 | @trigger_error('class:session_builder is deprecated since version 2.3 and will be removed in 3.0. Use session_builder config key instead with a service id.', E_USER_DEPRECATED); |
||
52 | return $v; |
||
53 | }) |
||
54 | ->end() |
||
55 | ->end() |
||
56 | ->scalarNode('session_builder')->defaultNull()->end() |
||
57 | ->scalarNode('pomm:default')->end() |
||
58 | ->end() |
||
59 | ->validate() |
||
60 | ->ifTrue(function ($v) { |
||
61 | return isset($v['session_builder']) && isset($v['class:session_builder']); |
||
62 | }) |
||
63 | ->thenInvalid('You cannot use both "session_builder" and "class:session_builder" at the same time.') |
||
64 | ->end() |
||
65 | ->beforeNormalization() |
||
66 | ->always() |
||
67 | ->then(function ($v) { |
||
68 | if (!isset($v['session_builder']) && !isset($v['class:session_builder'])) { |
||
69 | $v['session_builder'] = 'pomm.model_manager.session_builder'; |
||
70 | } |
||
71 | return $v; |
||
72 | }) |
||
73 | ->end() |
||
74 | ->end() |
||
75 | ->end() |
||
76 | ->arrayNode('logger') |
||
77 | ->children() |
||
78 | ->scalarNode('service')->end() |
||
79 | ->end() |
||
80 | ->end() |
||
81 | ->end(); |
||
82 | |||
83 | return $treeBuilder; |
||
84 | } |
||
85 | } |
||
86 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.