| Conditions | 3 |
| Paths | 4 |
| Total Lines | 123 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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, string $name = null ) : \Aimeos\Controller\Jobs\Iface |
||
| 34 | { |
||
| 35 | /** controller/jobs/order/email/delivery/name |
||
| 36 | * Class name of the used order email delivery scheduler controller implementation |
||
| 37 | * |
||
| 38 | * Each default job 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\Order\Email\Delivery\Standard |
||
| 46 | * |
||
| 47 | * and you want to replace it with your own version named |
||
| 48 | * |
||
| 49 | * \Aimeos\Controller\Jobs\Order\Email\Delivery\Mydelivery |
||
| 50 | * |
||
| 51 | * then you have to set the this configuration option: |
||
| 52 | * |
||
| 53 | * controller/jobs/order/email/delivery/name = Mydelivery |
||
| 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 "MyDelivery"! |
||
| 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->config()->get( 'controller/jobs/order/email/delivery/name', 'Standard' ); |
||
| 70 | } |
||
| 71 | |||
| 72 | $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
||
| 73 | $classname = '\\Aimeos\\Controller\\Jobs\\Order\\Email\\Delivery\\' . $name; |
||
| 74 | |||
| 75 | if( ctype_alnum( $name ) === false ) { |
||
| 76 | throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
||
| 77 | } |
||
| 78 | |||
| 79 | $controller = self::createController( $context, $aimeos, $classname, $iface ); |
||
| 80 | |||
| 81 | /** controller/jobs/order/email/delivery/decorators/excludes |
||
| 82 | * Excludes decorators added by the "common" option from the order email delivery controllers |
||
| 83 | * |
||
| 84 | * Decorators extend the functionality of a class by adding new aspects |
||
| 85 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 86 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 87 | * modify what is returned to the caller. |
||
| 88 | * |
||
| 89 | * This option allows you to remove a decorator added via |
||
| 90 | * "controller/jobs/common/decorators/default" before they are wrapped |
||
| 91 | * around the job controller. |
||
| 92 | * |
||
| 93 | * controller/jobs/order/email/delivery/decorators/excludes = array( 'decorator1' ) |
||
| 94 | * |
||
| 95 | * This would remove the decorator named "decorator1" from the list of |
||
| 96 | * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
||
| 97 | * "controller/jobs/common/decorators/default" to this job controller. |
||
| 98 | * |
||
| 99 | * @param array List of decorator names |
||
| 100 | * @since 2015.09 |
||
| 101 | * @category Developer |
||
| 102 | * @see controller/jobs/common/decorators/default |
||
| 103 | * @see controller/jobs/order/email/delivery/decorators/global |
||
| 104 | * @see controller/jobs/order/email/delivery/decorators/local |
||
| 105 | */ |
||
| 106 | |||
| 107 | /** controller/jobs/order/email/delivery/decorators/global |
||
| 108 | * Adds a list of globally available decorators only to the order email delivery controllers |
||
| 109 | * |
||
| 110 | * Decorators extend the functionality of a class by adding new aspects |
||
| 111 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 112 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 113 | * modify what is returned to the caller. |
||
| 114 | * |
||
| 115 | * This option allows you to wrap global decorators |
||
| 116 | * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
||
| 117 | * |
||
| 118 | * controller/jobs/order/email/delivery/decorators/global = array( 'decorator1' ) |
||
| 119 | * |
||
| 120 | * This would add the decorator named "decorator1" defined by |
||
| 121 | * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller. |
||
| 122 | * |
||
| 123 | * @param array List of decorator names |
||
| 124 | * @since 2015.09 |
||
| 125 | * @category Developer |
||
| 126 | * @see controller/jobs/common/decorators/default |
||
| 127 | * @see controller/jobs/order/email/delivery/decorators/excludes |
||
| 128 | * @see controller/jobs/order/email/delivery/decorators/local |
||
| 129 | */ |
||
| 130 | |||
| 131 | /** controller/jobs/order/email/delivery/decorators/local |
||
| 132 | * Adds a list of local decorators only to the order email delivery controllers |
||
| 133 | * |
||
| 134 | * Decorators extend the functionality of a class by adding new aspects |
||
| 135 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 136 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 137 | * modify what is returned to the caller. |
||
| 138 | * |
||
| 139 | * This option allows you to wrap local decorators |
||
| 140 | * ("\Aimeos\Controller\Jobs\Order\Email\Delivery\Decorator\*") around this job controller. |
||
| 141 | * |
||
| 142 | * controller/jobs/order/email/delivery/decorators/local = array( 'decorator2' ) |
||
| 143 | * |
||
| 144 | * This would add the decorator named "decorator2" defined by |
||
| 145 | * "\Aimeos\Controller\Jobs\Order\Email\Delivery\Decorator\Decorator2" only to this job |
||
| 146 | * controller. |
||
| 147 | * |
||
| 148 | * @param array List of decorator names |
||
| 149 | * @since 2015.09 |
||
| 150 | * @category Developer |
||
| 151 | * @see controller/jobs/common/decorators/default |
||
| 152 | * @see controller/jobs/order/email/delivery/decorators/excludes |
||
| 153 | * @see controller/jobs/order/email/delivery/decorators/global |
||
| 154 | */ |
||
| 155 | return self::addControllerDecorators( $context, $aimeos, $controller, 'order/email/delivery' ); |
||
| 156 | } |
||
| 158 |