Conditions | 1 |
Paths | 1 |
Total Lines | 97 |
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 |
||
100 | private function getManagersNode() |
||
101 | { |
||
102 | $builder = new TreeBuilder(); |
||
103 | $node = $builder->root('managers'); |
||
104 | |||
105 | $node |
||
106 | ->useAttributeAsKey('name') |
||
107 | ->info('Maps managers to connections and bundles') |
||
108 | ->prototype('array') |
||
109 | ->children() |
||
110 | ->arrayNode('index') |
||
111 | ->children() |
||
112 | ->scalarNode('index_name') |
||
113 | ->isRequired() |
||
114 | ->info('Sets index name for connection.') |
||
115 | ->end() |
||
116 | ->arrayNode('hosts') |
||
117 | ->info('Defines hosts to connect to.') |
||
118 | ->defaultValue(['127.0.0.1:9200']) |
||
119 | ->prototype('scalar') |
||
120 | ->end() |
||
121 | ->end() |
||
122 | ->arrayNode('settings') |
||
123 | ->defaultValue( |
||
124 | [ |
||
125 | 'number_of_replicas' => 0, |
||
126 | 'number_of_shards' => 1, |
||
127 | 'refresh_interval' => -1, |
||
128 | ] |
||
129 | ) |
||
130 | ->info('Sets index settings for connection.') |
||
131 | ->prototype('variable')->end() |
||
132 | ->end() |
||
133 | ->end() |
||
134 | ->end() |
||
135 | ->integerNode('bulk_size') |
||
136 | ->min(0) |
||
137 | ->defaultValue(100) |
||
138 | ->info( |
||
139 | 'Maximum documents size in the bulk container. ' . |
||
140 | 'When the limit is reached it will auto-commit.' |
||
141 | ) |
||
142 | ->end() |
||
143 | ->enumNode('commit_mode') |
||
144 | ->values(['refresh', 'flush', 'none']) |
||
145 | ->defaultValue('refresh') |
||
146 | ->info( |
||
147 | 'The default type of commit for bulk queries.' |
||
148 | ) |
||
149 | ->end() |
||
150 | ->arrayNode('logger') |
||
151 | ->info('Enables elasticsearch queries logging') |
||
152 | ->addDefaultsIfNotSet() |
||
153 | ->beforeNormalization() |
||
154 | ->ifTrue( |
||
155 | function ($v) { |
||
156 | return is_bool($v); |
||
157 | } |
||
158 | ) |
||
159 | ->then( |
||
160 | function ($v) { |
||
161 | return ['enabled' => $v]; |
||
162 | } |
||
163 | ) |
||
164 | ->end() |
||
165 | ->children() |
||
166 | ->booleanNode('enabled') |
||
167 | ->info('enables logging') |
||
168 | ->defaultFalse() |
||
169 | ->end() |
||
170 | ->scalarNode('level') |
||
171 | ->info('Sets PSR logging level.') |
||
172 | ->defaultValue(LogLevel::WARNING) |
||
173 | ->validate() |
||
174 | ->ifNotInArray((new \ReflectionClass('Psr\Log\LogLevel'))->getConstants()) |
||
175 | ->thenInvalid('Invalid PSR log level.') |
||
176 | ->end() |
||
177 | ->end() |
||
178 | ->scalarNode('log_file_name') |
||
179 | ->info('Log filename. The default name is the index name.') |
||
180 | ->defaultValue(null) |
||
181 | ->end() |
||
182 | ->end() |
||
183 | ->end() |
||
184 | ->arrayNode('mappings') |
||
185 | ->info('Maps manager to the bundles. f.e. AppBundle') |
||
186 | ->prototype('variable')->end() |
||
187 | ->end() |
||
188 | ->booleanNode('force_commit') |
||
189 | ->info('Forces commit to the elasticsearch on kernel terminate event.') |
||
190 | ->defaultTrue() |
||
191 | ->end() |
||
192 | ->end() |
||
193 | ->end(); |
||
194 | |||
195 | return $node; |
||
196 | } |
||
197 | |||
302 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.