Conditions | 4 |
Paths | 6 |
Total Lines | 133 |
Code Lines | 11 |
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 |
||
120 | protected static function createRoot( \Aimeos\MShop\Context\Item\Iface $context, |
||
121 | \Aimeos\Bootstrap $aimeos, $path, $name = null ) |
||
122 | { |
||
123 | /** admin/jsonadm/name |
||
124 | * Class name of the used JSON API client implementation |
||
125 | * |
||
126 | * Each default JSON API client can be replace by an alternative imlementation. |
||
127 | * To use this implementation, you have to set the last part of the class |
||
128 | * name as configuration value so the client factory knows which class it |
||
129 | * has to instantiate. |
||
130 | * |
||
131 | * For example, if the name of the default class is |
||
132 | * |
||
133 | * \Aimeos\Admin\JsonAdm\Standard |
||
134 | * |
||
135 | * and you want to replace it with your own version named |
||
136 | * |
||
137 | * \Aimeos\Admin\JsonAdm\Mycntl |
||
138 | * |
||
139 | * then you have to set the this configuration option: |
||
140 | * |
||
141 | * admin/jsonadm/name = Mycntl |
||
142 | * |
||
143 | * The value is the last part of your own class name and it's case sensitive, |
||
144 | * so take care that the configuration value is exactly named like the last |
||
145 | * part of the class name. |
||
146 | * |
||
147 | * The allowed characters of the class name are A-Z, a-z and 0-9. No other |
||
148 | * characters are possible! You should always start the last part of the class |
||
149 | * name with an upper case character and continue only with lower case characters |
||
150 | * or numbers. Avoid chamel case names like "MyCntl"! |
||
151 | * |
||
152 | * @param string Last part of the class name |
||
153 | * @since 2015.12 |
||
154 | * @category Developer |
||
155 | */ |
||
156 | if( $name === null ) { |
||
157 | $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
||
158 | } |
||
159 | |||
160 | if( ctype_alnum( $name ) === false ) |
||
161 | { |
||
162 | $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
||
163 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
||
164 | } |
||
165 | |||
166 | $view = $context->getView(); |
||
167 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
||
168 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
||
169 | |||
170 | $client = self::createAdmin( $classname, $iface, $context, $path ); |
||
171 | |||
172 | /** admin/jsonadm/decorators/excludes |
||
173 | * Excludes decorators added by the "common" option from the JSON API clients |
||
174 | * |
||
175 | * Decorators extend the functionality of a class by adding new aspects |
||
176 | * (e.g. log what is currently done), executing the methods of the underlying |
||
177 | * class only in certain conditions (e.g. only for logged in users) or |
||
178 | * modify what is returned to the caller. |
||
179 | * |
||
180 | * This option allows you to remove a decorator added via |
||
181 | * "admin/jsonadm/common/decorators/default" before they are wrapped |
||
182 | * around the Jsonadm client. |
||
183 | * |
||
184 | * admin/jsonadm/decorators/excludes = array( 'decorator1' ) |
||
185 | * |
||
186 | * This would remove the decorator named "decorator1" from the list of |
||
187 | * common decorators ("\Aimeos\Admin\JsonAdm\Common\Decorator\*") added via |
||
188 | * "admin/jsonadm/common/decorators/default" for the JSON API client. |
||
189 | * |
||
190 | * @param array List of decorator names |
||
191 | * @since 2016.01 |
||
192 | * @category Developer |
||
193 | * @see admin/jsonadm/common/decorators/default |
||
194 | * @see admin/jsonadm/decorators/global |
||
195 | * @see admin/jsonadm/decorators/local |
||
196 | */ |
||
197 | |||
198 | /** admin/jsonadm/decorators/global |
||
199 | * Adds a list of globally available decorators only to the Jsonadm client |
||
200 | * |
||
201 | * Decorators extend the functionality of a class by adding new aspects |
||
202 | * (e.g. log what is currently done), executing the methods of the underlying |
||
203 | * class only in certain conditions (e.g. only for logged in users) or |
||
204 | * modify what is returned to the caller. |
||
205 | * |
||
206 | * This option allows you to wrap global decorators |
||
207 | * ("\Aimeos\Admin\Jsonadm\Common\Decorator\*") around the Jsonadm |
||
208 | * client. |
||
209 | * |
||
210 | * admin/jsonadm/product/decorators/global = array( 'decorator1' ) |
||
211 | * |
||
212 | * This would add the decorator named "decorator1" defined by |
||
213 | * "\Aimeos\Admin\Jsonadm\Common\Decorator\Decorator1" only to the |
||
214 | * "product" Jsonadm client. |
||
215 | * |
||
216 | * @param array List of decorator names |
||
217 | * @since 2016.01 |
||
218 | * @category Developer |
||
219 | * @see admin/jsonadm/common/decorators/default |
||
220 | * @see admin/jsonadm/decorators/excludes |
||
221 | * @see admin/jsonadm/decorators/local |
||
222 | */ |
||
223 | |||
224 | /** admin/jsonadm/decorators/local |
||
225 | * Adds a list of local decorators only to the Jsonadm client |
||
226 | * |
||
227 | * Decorators extend the functionality of a class by adding new aspects |
||
228 | * (e.g. log what is currently done), executing the methods of the underlying |
||
229 | * class only in certain conditions (e.g. only for logged in users) or |
||
230 | * modify what is returned to the caller. |
||
231 | * |
||
232 | * This option allows you to wrap local decorators |
||
233 | * ("\Aimeos\Admin\Jsonadm\Product\Decorator\*") around the Jsonadm |
||
234 | * client. |
||
235 | * |
||
236 | * admin/jsonadm/product/decorators/local = array( 'decorator2' ) |
||
237 | * |
||
238 | * This would add the decorator named "decorator2" defined by |
||
239 | * "\Aimeos\Admin\Jsonadm\Product\Decorator\Decorator2" only to the |
||
240 | * "product" Jsonadm client. |
||
241 | * |
||
242 | * @param array List of decorator names |
||
243 | * @since 2016.01 |
||
244 | * @category Developer |
||
245 | * @see admin/jsonadm/common/decorators/default |
||
246 | * @see admin/jsonadm/decorators/excludes |
||
247 | * @see admin/jsonadm/decorators/global |
||
248 | */ |
||
249 | |||
250 | $client = self::addClientDecorators( $client, $context, $path ); |
||
251 | |||
252 | return $client->setAimeos( $aimeos )->setView( $view ); |
||
253 | } |
||
255 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths