| Conditions | 4 | 
| Paths | 6 | 
| Total Lines | 126 | 
| 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  | 
            ||
| 33 | public static function create( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null )  | 
            ||
| 34 | 	{ | 
            ||
| 35 | /** controller/jobs/admin/cache/name  | 
            ||
| 36 | * Class name of the used admin cache scheduler controller implementation  | 
            ||
| 37 | *  | 
            ||
| 38 | * Each default cache controller can be replace by an alternative imlementation.  | 
            ||
| 39 | * To use this implementation, you have to set the last part of the class  | 
            ||
| 40 | * name as configuration value so the controller factory knows which class it  | 
            ||
| 41 | * has to instantiate.  | 
            ||
| 42 | *  | 
            ||
| 43 | * For example, if the name of the default class is  | 
            ||
| 44 | *  | 
            ||
| 45 | * \Aimeos\Controller\Jobs\Admin\Cache\Standard  | 
            ||
| 46 | *  | 
            ||
| 47 | * and you want to replace it with your own version named  | 
            ||
| 48 | *  | 
            ||
| 49 | * \Aimeos\Controller\Jobs\Admin\Cache\Mycache  | 
            ||
| 50 | *  | 
            ||
| 51 | * then you have to set the this configuration option:  | 
            ||
| 52 | *  | 
            ||
| 53 | * controller/jobs/admin/cache/name = Mycache  | 
            ||
| 54 | *  | 
            ||
| 55 | * The value is the last part of your own class name and it's case sensitive,  | 
            ||
| 56 | * so take care that the configuration value is exactly named like the last  | 
            ||
| 57 | * part of the class name.  | 
            ||
| 58 | *  | 
            ||
| 59 | * The allowed characters of the class name are A-Z, a-z and 0-9. No other  | 
            ||
| 60 | * characters are possible! You should always start the last part of the class  | 
            ||
| 61 | * name with an upper case character and continue only with lower case characters  | 
            ||
| 62 | * or numbers. Avoid chamel case names like "MyCache"!  | 
            ||
| 63 | *  | 
            ||
| 64 | * @param string Last part of the class name  | 
            ||
| 65 | * @since 2014.03  | 
            ||
| 66 | * @category Developer  | 
            ||
| 67 | */  | 
            ||
| 68 | 		if( $name === null ) { | 
            ||
| 69 | $name = $context->getConfig()->get( 'controller/jobs/admin/cache/name', 'Standard' );  | 
            ||
| 70 | }  | 
            ||
| 71 | |||
| 72 | if( ctype_alnum( $name ) === false )  | 
            ||
| 73 | 		{ | 
            ||
| 74 | $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Admin\\Cache\\' . $name : '<not a string>';  | 
            ||
| 75 | throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );  | 
            ||
| 76 | }  | 
            ||
| 77 | |||
| 78 | $iface = '\\Aimeos\\Controller\\Jobs\\Iface';  | 
            ||
| 79 | $classname = '\\Aimeos\\Controller\\Jobs\\Admin\\Cache\\' . $name;  | 
            ||
| 80 | |||
| 81 | $controller = self::createController( $context, $aimeos, $classname, $iface );  | 
            ||
| 82 | |||
| 83 | /** controller/jobs/admin/cache/decorators/excludes  | 
            ||
| 84 | * Excludes decorators added by the "common" option from the admin cache controllers  | 
            ||
| 85 | *  | 
            ||
| 86 | * Decorators extend the functionality of a class by adding new aspects  | 
            ||
| 87 | * (e.g. log what is currently done), executing the methods of the underlying  | 
            ||
| 88 | * class only in certain conditions (e.g. only for logged in users) or  | 
            ||
| 89 | * modify what is returned to the caller.  | 
            ||
| 90 | *  | 
            ||
| 91 | * This option allows you to remove a decorator added via  | 
            ||
| 92 | * "controller/jobs/common/decorators/default" before they are wrapped  | 
            ||
| 93 | * around the job controller.  | 
            ||
| 94 | *  | 
            ||
| 95 | * controller/jobs/admin/cache/decorators/excludes = array( 'decorator1' )  | 
            ||
| 96 | *  | 
            ||
| 97 | * This would remove the decorator named "decorator1" from the list of  | 
            ||
| 98 | 		 * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via | 
            ||
| 99 | * "controller/jobs/common/decorators/default" to this job controller.  | 
            ||
| 100 | *  | 
            ||
| 101 | * @param array List of decorator names  | 
            ||
| 102 | * @since 2015.09  | 
            ||
| 103 | * @category Developer  | 
            ||
| 104 | * @see controller/jobs/common/decorators/default  | 
            ||
| 105 | * @see controller/jobs/admin/cache/decorators/global  | 
            ||
| 106 | * @see controller/jobs/admin/cache/decorators/local  | 
            ||
| 107 | */  | 
            ||
| 108 | |||
| 109 | /** controller/jobs/admin/cache/decorators/global  | 
            ||
| 110 | * Adds a list of globally available decorators only to the admin cache controllers  | 
            ||
| 111 | *  | 
            ||
| 112 | * Decorators extend the functionality of a class by adding new aspects  | 
            ||
| 113 | * (e.g. log what is currently done), executing the methods of the underlying  | 
            ||
| 114 | * class only in certain conditions (e.g. only for logged in users) or  | 
            ||
| 115 | * modify what is returned to the caller.  | 
            ||
| 116 | *  | 
            ||
| 117 | * This option allows you to wrap global decorators  | 
            ||
| 118 | 		 * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. | 
            ||
| 119 | *  | 
            ||
| 120 | * controller/jobs/admin/cache/decorators/global = array( 'decorator1' )  | 
            ||
| 121 | *  | 
            ||
| 122 | * This would add the decorator named "decorator1" defined by  | 
            ||
| 123 | * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller.  | 
            ||
| 124 | *  | 
            ||
| 125 | * @param array List of decorator names  | 
            ||
| 126 | * @since 2015.09  | 
            ||
| 127 | * @category Developer  | 
            ||
| 128 | * @see controller/jobs/common/decorators/default  | 
            ||
| 129 | * @see controller/jobs/admin/cache/decorators/excludes  | 
            ||
| 130 | * @see controller/jobs/admin/cache/decorators/local  | 
            ||
| 131 | */  | 
            ||
| 132 | |||
| 133 | /** controller/jobs/admin/cache/decorators/local  | 
            ||
| 134 | * Adds a list of local decorators only to the admin cache controllers  | 
            ||
| 135 | *  | 
            ||
| 136 | * Decorators extend the functionality of a class by adding new aspects  | 
            ||
| 137 | * (e.g. log what is currently done), executing the methods of the underlying  | 
            ||
| 138 | * class only in certain conditions (e.g. only for logged in users) or  | 
            ||
| 139 | * modify what is returned to the caller.  | 
            ||
| 140 | *  | 
            ||
| 141 | * This option allows you to wrap local decorators  | 
            ||
| 142 | 		 * ("\Aimeos\Controller\Jobs\Admin\Cache\Decorator\*") around this job controller. | 
            ||
| 143 | *  | 
            ||
| 144 | * controller/jobs/admin/cache/decorators/local = array( 'decorator2' )  | 
            ||
| 145 | *  | 
            ||
| 146 | * This would add the decorator named "decorator2" defined by  | 
            ||
| 147 | * "\Aimeos\Controller\Jobs\Admin\Cache\Decorator\Decorator2" only to this job  | 
            ||
| 148 | * controller.  | 
            ||
| 149 | *  | 
            ||
| 150 | * @param array List of decorator names  | 
            ||
| 151 | * @since 2015.09  | 
            ||
| 152 | * @category Developer  | 
            ||
| 153 | * @see controller/jobs/common/decorators/default  | 
            ||
| 154 | * @see controller/jobs/admin/cache/decorators/excludes  | 
            ||
| 155 | * @see controller/jobs/admin/cache/decorators/global  | 
            ||
| 156 | */  | 
            ||
| 157 | return self::addControllerDecorators( $context, $aimeos, $controller, 'admin/cache' );  | 
            ||
| 158 | }  | 
            ||
| 159 | }  |