| Conditions | 9 | 
| Paths | 1 | 
| Total Lines | 148 | 
| Code Lines | 133 | 
| 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  | 
            ||
| 23 | public function getConfigTreeBuilder(): TreeBuilder  | 
            ||
| 24 |     { | 
            ||
| 25 | $treeBuilder = new TreeBuilder();  | 
            ||
| 26 |         $rootNode = $treeBuilder->root('ekino_new_relic'); | 
            ||
| 27 | |||
| 28 | $rootNode  | 
            ||
| 29 |             ->fixXmlConfig('deployment_name') | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 30 | ->children()  | 
            ||
| 31 |                 ->booleanNode('enabled')->defaultTrue()->end() | 
            ||
| 32 |                 ->scalarNode('interactor')->end() | 
            ||
| 33 |                 ->booleanNode('twig')->defaultValue(\class_exists('\Twig_Environment'))->end() | 
            ||
| 34 |                 ->scalarNode('api_key')->defaultValue(null)->end() | 
            ||
| 35 |                 ->scalarNode('license_key')->defaultValue(null)->end() | 
            ||
| 36 |                 ->scalarNode('application_name')->defaultValue(null)->end() | 
            ||
| 37 |                 ->arrayNode('deployment_names') | 
            ||
| 38 |                     ->prototype('scalar') | 
            ||
| 39 | ->end()  | 
            ||
| 40 | ->beforeNormalization()  | 
            ||
| 41 |                         ->ifTrue(function ($v) { return !\is_array($v); }) | 
            ||
| 42 |                         ->then(function ($v) { return \array_values(\array_filter(\explode(';', $v))); }) | 
            ||
| 43 | ->end()  | 
            ||
| 44 | ->end()  | 
            ||
| 45 |                 ->scalarNode('xmit')->defaultValue(false)->end() | 
            ||
| 46 |                 ->booleanNode('logging') | 
            ||
| 47 |                     ->info('Write logs to a PSR3 logger whenever we send data to NewRelic.') | 
            ||
| 48 | ->defaultFalse()  | 
            ||
| 49 | ->end()  | 
            ||
| 50 |                 ->arrayNode('exceptions') | 
            ||
| 51 | ->canBeDisabled()  | 
            ||
| 52 | ->end()  | 
            ||
| 53 |                 ->arrayNode('commands') | 
            ||
| 54 | ->canBeDisabled()  | 
            ||
| 55 | ->children()  | 
            ||
| 56 |                         ->arrayNode('ignored_commands') | 
            ||
| 57 |                             ->prototype('scalar') | 
            ||
| 58 | ->end()  | 
            ||
| 59 | ->beforeNormalization()  | 
            ||
| 60 |                                 ->ifTrue(function ($v) { return !\is_array($v); }) | 
            ||
| 61 |                                 ->then(function ($v) { return (array) $v; }) | 
            ||
| 62 | ->end()  | 
            ||
| 63 | ->end()  | 
            ||
| 64 | ->end()  | 
            ||
| 65 | ->end()  | 
            ||
| 66 |                 ->arrayNode('deprecations') | 
            ||
| 67 | ->canBeDisabled()  | 
            ||
| 68 | ->end()  | 
            ||
| 69 |                 ->arrayNode('http') | 
            ||
| 70 | ->canBeDisabled()  | 
            ||
| 71 | ->children()  | 
            ||
| 72 |                         ->scalarNode('transaction_naming') | 
            ||
| 73 |                             ->defaultValue('route') | 
            ||
| 74 | ->validate()  | 
            ||
| 75 | ->ifNotInArray(['route', 'controller', 'service'])  | 
            ||
| 76 |                                 ->thenInvalid('Invalid transaction naming scheme "%s", must be "route", "controller" or "service".') | 
            ||
| 77 | ->end()  | 
            ||
| 78 | ->end()  | 
            ||
| 79 |                         ->scalarNode('transaction_naming_service')->defaultNull()->end() | 
            ||
| 80 |                         ->arrayNode('ignored_routes') | 
            ||
| 81 |                             ->prototype('scalar') | 
            ||
| 82 | ->end()  | 
            ||
| 83 | ->beforeNormalization()  | 
            ||
| 84 |                                 ->ifTrue(function ($v) { return !\is_array($v); }) | 
            ||
| 85 |                                 ->then(function ($v) { return (array) $v; }) | 
            ||
| 86 | ->end()  | 
            ||
| 87 | ->end()  | 
            ||
| 88 |                         ->arrayNode('ignored_paths') | 
            ||
| 89 |                             ->prototype('scalar') | 
            ||
| 90 | ->end()  | 
            ||
| 91 | ->beforeNormalization()  | 
            ||
| 92 |                                 ->ifTrue(function ($v) { return !\is_array($v); }) | 
            ||
| 93 |                                 ->then(function ($v) { return (array) $v; }) | 
            ||
| 94 | ->end()  | 
            ||
| 95 | ->end()  | 
            ||
| 96 |                         ->scalarNode('using_symfony_cache')->defaultFalse()->end() | 
            ||
| 97 | ->end()  | 
            ||
| 98 | ->end()  | 
            ||
| 99 |                 ->booleanNode('instrument') | 
            ||
| 100 | ->defaultFalse()  | 
            ||
| 101 | ->end()  | 
            ||
| 102 |                 ->arrayNode('monolog') | 
            ||
| 103 | ->canBeEnabled()  | 
            ||
| 104 | ->children()  | 
            ||
| 105 |                         ->arrayNode('channels') | 
            ||
| 106 |                             ->fixXmlConfig('channel', 'elements') | 
            ||
| 107 | ->canBeUnset()  | 
            ||
| 108 | ->beforeNormalization()  | 
            ||
| 109 | ->ifString()  | 
            ||
| 110 |                                 ->then(function ($v) { return ['elements' => [$v]]; }) | 
            ||
| 111 | ->end()  | 
            ||
| 112 | ->beforeNormalization()  | 
            ||
| 113 |                                 ->ifTrue(function ($v) { return \is_array($v) && \is_numeric(\key($v)); }) | 
            ||
| 114 |                                 ->then(function ($v) { return ['elements' => $v]; }) | 
            ||
| 115 | ->end()  | 
            ||
| 116 | ->validate()  | 
            ||
| 117 |                                 ->ifTrue(function ($v) { return empty($v); }) | 
            ||
| 118 | ->thenUnset()  | 
            ||
| 119 | ->end()  | 
            ||
| 120 | ->validate()  | 
            ||
| 121 |                                 ->always(function ($v) { | 
            ||
| 122 | $isExclusive = null;  | 
            ||
| 123 |                                     if (isset($v['type'])) { | 
            ||
| 124 | $isExclusive = 'exclusive' === $v['type'];  | 
            ||
| 125 | }  | 
            ||
| 126 | |||
| 127 | $elements = [];  | 
            ||
| 128 |                                     foreach ($v['elements'] as $element) { | 
            ||
| 129 |                                         if (0 === \strpos($element, '!')) { | 
            ||
| 130 |                                             if (false === $isExclusive) { | 
            ||
| 131 |                                                 throw new InvalidConfigurationException('Cannot combine exclusive/inclusive definitions in channels list.'); | 
            ||
| 132 | }  | 
            ||
| 133 | $elements[] = \substr($element, 1);  | 
            ||
| 134 | $isExclusive = true;  | 
            ||
| 135 |                                         } else { | 
            ||
| 136 |                                             if (true === $isExclusive) { | 
            ||
| 137 |                                                 throw new InvalidConfigurationException('Cannot combine exclusive/inclusive definitions in channels list'); | 
            ||
| 138 | }  | 
            ||
| 139 | $elements[] = $element;  | 
            ||
| 140 | $isExclusive = false;  | 
            ||
| 141 | }  | 
            ||
| 142 | }  | 
            ||
| 143 | |||
| 144 |                                     if (!\count($elements)) { | 
            ||
| 145 | return;  | 
            ||
| 146 | }  | 
            ||
| 147 | |||
| 148 | return ['type' => $isExclusive ? 'exclusive' : 'inclusive', 'elements' => $elements];  | 
            ||
| 149 | })  | 
            ||
| 150 | ->end()  | 
            ||
| 151 | ->children()  | 
            ||
| 152 |                                 ->scalarNode('type') | 
            ||
| 153 | ->validate()  | 
            ||
| 154 | ->ifNotInArray(['inclusive', 'exclusive'])  | 
            ||
| 155 |                                         ->thenInvalid('The type of channels has to be inclusive or exclusive') | 
            ||
| 156 | ->end()  | 
            ||
| 157 | ->end()  | 
            ||
| 158 |                                 ->arrayNode('elements') | 
            ||
| 159 |                                     ->prototype('scalar')->end() | 
            ||
| 160 | ->end()  | 
            ||
| 161 | ->end()  | 
            ||
| 162 | ->end()  | 
            ||
| 163 |                         ->scalarNode('level')->defaultValue(LogLevel::ERROR)->end() | 
            ||
| 164 |                         ->scalarNode('service')->defaultValue('ekino.new_relic.monolog_handler')->end() | 
            ||
| 165 | ->end()  | 
            ||
| 166 | ->end()  | 
            ||
| 167 | ->end()  | 
            ||
| 168 | ;  | 
            ||
| 169 | |||
| 170 | return $treeBuilder;  | 
            ||
| 171 | }  | 
            ||
| 173 |