| Conditions | 4 | 
| Paths | 6 | 
| Total Lines | 131 | 
| 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  | 
            ||
| 160 | * @since 2015.12  | 
            ||
| 161 | * @category Developer  | 
            ||
| 162 | */  | 
            ||
| 163 | |||
| 164 | $name = ( $name ?: $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ) );  | 
            ||
| 165 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name;  | 
            ||
| 166 | }  | 
            ||
| 167 | |||
| 168 | |||
| 169 | if( ctype_alnum( $name ) === false )  | 
            ||
| 170 | 		{ | 
            ||
| 171 | $classname = is_string( $name ) ? $classname : '<not a string>';  | 
            ||
| 172 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );  | 
            ||
| 173 | }  | 
            ||
| 174 | |||
| 175 | $view = $context->getView();  | 
            ||
| 176 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface';  | 
            ||
| 177 | |||
| 178 | $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );  | 
            ||
| 179 | |||
| 180 | /** admin/jsonadm/decorators/excludes  | 
            ||
| 181 | * Excludes decorators added by the "common" option from the JSON API clients  | 
            ||
| 182 | *  | 
            ||
| 183 | * Decorators extend the functionality of a class by adding new aspects  | 
            ||
| 184 | * (e.g. log what is currently done), executing the methods of the underlying  | 
            ||
| 185 | * class only in certain conditions (e.g. only for logged in users) or  | 
            ||
| 186 | * modify what is returned to the caller.  | 
            ||
| 187 | *  | 
            ||
| 188 | * This option allows you to remove a decorator added via  | 
            ||
| 189 | * "admin/jsonadm/common/decorators/default" before they are wrapped  | 
            ||
| 190 | * around the Jsonadm client.  | 
            ||
| 191 | *  | 
            ||
| 192 | * admin/jsonadm/decorators/excludes = array( 'decorator1' )  | 
            ||
| 193 | *  | 
            ||
| 194 | * This would remove the decorator named "decorator1" from the list of  | 
            ||
| 195 | 		 * common decorators ("\Aimeos\Admin\JsonAdm\Common\Decorator\*") added via | 
            ||
| 196 | * "admin/jsonadm/common/decorators/default" for the JSON API client.  | 
            ||
| 197 | *  | 
            ||
| 198 | * @param array List of decorator names  | 
            ||
| 199 | * @since 2016.01  | 
            ||
| 200 | * @category Developer  | 
            ||
| 201 | * @see admin/jsonadm/common/decorators/default  | 
            ||
| 202 | * @see admin/jsonadm/decorators/global  | 
            ||
| 203 | * @see admin/jsonadm/decorators/local  | 
            ||
| 204 | */  | 
            ||
| 205 | |||
| 206 | /** admin/jsonadm/decorators/global  | 
            ||
| 207 | * Adds a list of globally available decorators only to the Jsonadm client  | 
            ||
| 208 | *  | 
            ||
| 209 | * Decorators extend the functionality of a class by adding new aspects  | 
            ||
| 210 | * (e.g. log what is currently done), executing the methods of the underlying  | 
            ||
| 211 | * class only in certain conditions (e.g. only for logged in users) or  | 
            ||
| 212 | * modify what is returned to the caller.  | 
            ||
| 213 | *  | 
            ||
| 214 | * This option allows you to wrap global decorators  | 
            ||
| 215 | 		 * ("\Aimeos\Admin\Jsonadm\Common\Decorator\*") around the Jsonadm | 
            ||
| 216 | * client.  | 
            ||
| 217 | *  | 
            ||
| 218 | * admin/jsonadm/product/decorators/global = array( 'decorator1' )  | 
            ||
| 219 | *  | 
            ||
| 220 | * This would add the decorator named "decorator1" defined by  | 
            ||
| 221 | * "\Aimeos\Admin\Jsonadm\Common\Decorator\Decorator1" only to the  | 
            ||
| 222 | * "product" Jsonadm client.  | 
            ||
| 223 | *  | 
            ||
| 224 | * @param array List of decorator names  | 
            ||
| 225 | * @since 2016.01  | 
            ||
| 226 | * @category Developer  | 
            ||
| 227 | * @see admin/jsonadm/common/decorators/default  | 
            ||
| 228 | * @see admin/jsonadm/decorators/excludes  | 
            ||
| 229 | * @see admin/jsonadm/decorators/local  | 
            ||
| 230 | */  | 
            ||
| 231 | |||
| 232 | /** admin/jsonadm/decorators/local  | 
            ||
| 233 | * Adds a list of local decorators only to the Jsonadm client  | 
            ||
| 234 | *  | 
            ||
| 235 | * Decorators extend the functionality of a class by adding new aspects  | 
            ||
| 236 | * (e.g. log what is currently done), executing the methods of the underlying  | 
            ||
| 237 | * class only in certain conditions (e.g. only for logged in users) or  | 
            ||
| 238 | * modify what is returned to the caller.  | 
            ||
| 239 | *  | 
            ||
| 240 | * This option allows you to wrap local decorators  | 
            ||
| 241 | 		 * ("\Aimeos\Admin\Jsonadm\Product\Decorator\*") around the Jsonadm | 
            ||
| 242 | * client.  | 
            ||
| 243 | *  | 
            ||
| 244 | * admin/jsonadm/product/decorators/local = array( 'decorator2' )  | 
            ||
| 245 | *  | 
            ||
| 246 | * This would add the decorator named "decorator2" defined by  | 
            ||
| 247 | * "\Aimeos\Admin\Jsonadm\Product\Decorator\Decorator2" only to the  | 
            ||
| 248 | * "product" Jsonadm client.  | 
            ||
| 249 | *  | 
            ||
| 250 | * @param array List of decorator names  | 
            ||
| 251 | * @since 2016.01  | 
            ||
| 252 | * @category Developer  | 
            ||
| 253 | * @see admin/jsonadm/common/decorators/default  | 
            ||
| 254 | * @see admin/jsonadm/decorators/excludes  | 
            ||
| 255 | * @see admin/jsonadm/decorators/global  | 
            ||
| 256 | */  | 
            ||
| 257 | |||
| 258 | return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );  | 
            ||
| 259 | }  | 
            ||
| 260 | }  | 
            ||
| 261 |