| Conditions | 3 |
| Paths | 2 |
| Total Lines | 67 |
| 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 |
||
| 16 | public function getConfigTreeBuilder() |
||
| 17 | { |
||
| 18 | $fixOptionKeys = function ($options) { |
||
| 19 | $fixedOptions = []; |
||
| 20 | foreach ($options as $key => $value) { |
||
| 21 | $fixedOptions[str_replace('_', '-', $key)] = $value; |
||
| 22 | } |
||
| 23 | |||
| 24 | return $fixedOptions; |
||
| 25 | }; |
||
| 26 | |||
| 27 | $treeBuilder = new TreeBuilder('knp_snappy'); |
||
| 28 | if (method_exists($treeBuilder, 'getRootNode')) { |
||
| 29 | $rootNode = $treeBuilder->getRootNode(); |
||
| 30 | } else { |
||
| 31 | // BC for symfony/config < 4.2 |
||
| 32 | $rootNode = $treeBuilder->root('knp_snappy'); |
||
|
|
|||
| 33 | } |
||
| 34 | |||
| 35 | $rootNode |
||
| 36 | ->children() |
||
| 37 | ->scalarNode('temporary_folder')->end() |
||
| 38 | ->integerNode('process_timeout') |
||
| 39 | ->min(1) |
||
| 40 | ->info('Generator process timeout in seconds.') |
||
| 41 | ->end() |
||
| 42 | ->arrayNode('pdf') |
||
| 43 | ->addDefaultsIfNotSet() |
||
| 44 | ->children() |
||
| 45 | ->booleanNode('enabled')->defaultTrue()->end() |
||
| 46 | ->scalarNode('binary')->defaultValue('wkhtmltopdf')->end() |
||
| 47 | ->arrayNode('options') |
||
| 48 | ->performNoDeepMerging() |
||
| 49 | ->useAttributeAsKey('name') |
||
| 50 | ->beforeNormalization() |
||
| 51 | ->always($fixOptionKeys) |
||
| 52 | ->end() |
||
| 53 | ->prototype('scalar')->end() |
||
| 54 | ->end() |
||
| 55 | ->arrayNode('env') |
||
| 56 | ->prototype('scalar')->end() |
||
| 57 | ->end() |
||
| 58 | ->end() |
||
| 59 | ->end() |
||
| 60 | ->arrayNode('image') |
||
| 61 | ->addDefaultsIfNotSet() |
||
| 62 | ->children() |
||
| 63 | ->booleanNode('enabled')->defaultTrue()->end() |
||
| 64 | ->scalarNode('binary')->defaultValue('wkhtmltoimage')->end() |
||
| 65 | ->arrayNode('options') |
||
| 66 | ->performNoDeepMerging() |
||
| 67 | ->useAttributeAsKey('name') |
||
| 68 | ->beforeNormalization() |
||
| 69 | ->always($fixOptionKeys) |
||
| 70 | ->end() |
||
| 71 | ->prototype('scalar')->end() |
||
| 72 | ->end() |
||
| 73 | ->arrayNode('env') |
||
| 74 | ->prototype('scalar')->end() |
||
| 75 | ->end() |
||
| 76 | ->end() |
||
| 77 | ->end() |
||
| 78 | ->end() |
||
| 79 | ; |
||
| 80 | |||
| 81 | return $treeBuilder; |
||
| 82 | } |
||
| 83 | } |
||
| 84 |
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.