| Conditions | 1 |
| Paths | 1 |
| Total Lines | 103 |
| Code Lines | 62 |
| 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 |
||
| 91 | public function addRecipes() { |
||
| 92 | // add default recipe, which should handle loading for most PSR-4 compatible classes |
||
| 93 | // as long as they are not type hinting for interfaces |
||
| 94 | $this->CoffeeShop->addRecipe( |
||
| 95 | new Recipe( |
||
| 96 | Recipe::DEFAULT_ID |
||
| 97 | ) |
||
| 98 | ); |
||
| 99 | // PSR-4 compatible class with aliases |
||
| 100 | $this->CoffeeShop->addRecipe( |
||
| 101 | new Recipe( |
||
| 102 | 'CommandHandlerManager', |
||
| 103 | 'EventEspresso\core\services\commands\CommandHandlerManager', |
||
| 104 | array( |
||
| 105 | 'CommandHandlerManagerInterface', |
||
| 106 | 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
||
| 107 | ), |
||
| 108 | array(), |
||
| 109 | CoffeeMaker::BREW_SHARED |
||
| 110 | ) |
||
| 111 | ); |
||
| 112 | // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager |
||
| 113 | $this->CoffeeShop->addRecipe( |
||
| 114 | new Recipe( |
||
| 115 | 'CommandBus', |
||
| 116 | 'EventEspresso\core\services\commands\CommandBus', |
||
| 117 | array( |
||
| 118 | 'CommandBusInterface', |
||
| 119 | 'EventEspresso\core\services\commands\CommandBusInterface', |
||
| 120 | ), |
||
| 121 | array(), |
||
| 122 | CoffeeMaker::BREW_SHARED |
||
| 123 | ) |
||
| 124 | ); |
||
| 125 | // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath |
||
| 126 | // add a wildcard recipe for loading legacy core interfaces |
||
| 127 | $this->CoffeeShop->addRecipe( |
||
| 128 | new Recipe( |
||
| 129 | 'EEI_*', |
||
| 130 | '', |
||
| 131 | array(), |
||
| 132 | array(), |
||
| 133 | CoffeeMaker::BREW_LOAD_ONLY, |
||
| 134 | array( |
||
| 135 | EE_INTERFACES . '*.php', |
||
| 136 | EE_INTERFACES . '*.interfaces.php', |
||
| 137 | ) |
||
| 138 | ) |
||
| 139 | ); |
||
| 140 | // add a wildcard recipe for loading models |
||
| 141 | $this->CoffeeShop->addRecipe( |
||
| 142 | new Recipe( |
||
| 143 | 'EEM_*', |
||
| 144 | '', |
||
| 145 | array(), |
||
| 146 | array(), |
||
| 147 | CoffeeMaker::BREW_SHARED, |
||
| 148 | EE_MODELS . '*.model.php' |
||
| 149 | ) |
||
| 150 | ); |
||
| 151 | // add a wildcard recipe for loading core classes |
||
| 152 | $this->CoffeeShop->addRecipe( |
||
| 153 | new Recipe( |
||
| 154 | 'EE_*', |
||
| 155 | '', |
||
| 156 | array(), |
||
| 157 | array(), |
||
| 158 | CoffeeMaker::BREW_SHARED, |
||
| 159 | array( |
||
| 160 | EE_CORE . '*.core.php', |
||
| 161 | EE_ADMIN . '*.core.php', |
||
| 162 | EE_CPTS . '*.core.php', |
||
| 163 | EE_CORE . 'data_migration_scripts' . DS . '*.core.php', |
||
| 164 | EE_CORE . 'request_stack' . DS . '*.core.php', |
||
| 165 | EE_CORE . 'middleware' . DS . '*.core.php', |
||
| 166 | ) |
||
| 167 | ) |
||
| 168 | ); |
||
| 169 | // load admin page parent class |
||
| 170 | $this->CoffeeShop->addRecipe( |
||
| 171 | new Recipe( |
||
| 172 | 'EE_Admin_Page*', |
||
| 173 | '', |
||
| 174 | array(), |
||
| 175 | array(), |
||
| 176 | CoffeeMaker::BREW_LOAD_ONLY, |
||
| 177 | array( EE_ADMIN . '*.core.php' ) |
||
| 178 | ) |
||
| 179 | ); |
||
| 180 | // add a wildcard recipe for loading core classes |
||
| 181 | // $this->CoffeeShop->addRecipe( |
||
| 182 | // new Recipe( |
||
| 183 | // '*_Admin_Page', |
||
| 184 | // '', |
||
| 185 | // array(), |
||
| 186 | // array(), |
||
| 187 | // CoffeeMaker::BREW_SHARED, |
||
| 188 | // array( |
||
| 189 | // EE_ADMIN_PAGES . 'transactions' . DS . '*.core.php', |
||
| 190 | // ) |
||
| 191 | // ) |
||
| 192 | // ); |
||
| 193 | } |
||
| 194 | |||
| 219 |