| Conditions | 3 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 35 |
| 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 |
||
| 39 | public function build(ServiceContainer $container) |
||
| 40 | { |
||
| 41 | $assembler = $this; |
||
| 42 | $container->addConfigurator(function ($c) use ($assembler) { |
||
| 43 | $config = $assembler->configuration; |
||
| 44 | |||
| 45 | $srcNS = $config->getNamespace(); |
||
| 46 | $specPrefix = $config->getSpecPrefix(); |
||
| 47 | $srcPath = $config->getSrcPath(); |
||
| 48 | $specPath = $config->getSpecPath(); |
||
| 49 | $codePool = $config->getCodePool(); |
||
| 50 | $filesystem = $c->get('filesystem'); |
||
| 51 | |||
| 52 | if (!$filesystem->isDirectory($srcPath)) { |
||
| 53 | $filesystem->makeDirectory($srcPath); |
||
| 54 | } |
||
| 55 | |||
| 56 | if (!$filesystem->isDirectory($specPath)) { |
||
| 57 | $filesystem->makeDirectory($specPath); |
||
| 58 | } |
||
| 59 | |||
| 60 | $factory = new LocatorFactory($srcNS, $specPrefix, $srcPath, $specPath, $filesystem, $codePool); |
||
| 61 | |||
| 62 | $c->define('locator.locators.magento.model_locator', |
||
| 63 | function () use ($factory) { |
||
| 64 | return $factory->getLocator('model'); |
||
| 65 | }, |
||
| 66 | ['locator.locators.magento'] |
||
| 67 | ); |
||
| 68 | |||
| 69 | $c->define('locator.locators.magento.block_locator', |
||
| 70 | function () use ($factory) { |
||
| 71 | return $factory->getLocator('block'); |
||
| 72 | }, |
||
| 73 | ['locator.locators.magento'] |
||
| 74 | ); |
||
| 75 | |||
| 76 | $c->define('locator.locators.magento.helper_locator', |
||
| 77 | function () use ($factory) { |
||
| 78 | return $factory->getLocator('helper'); |
||
| 79 | }, |
||
| 80 | ['locator.locators.magento'] |
||
| 81 | ); |
||
| 82 | |||
| 83 | $c->define('locator.locators.magento.controller_locator', |
||
| 84 | function () use ($factory) { |
||
| 85 | return $factory->getLocator('controller'); |
||
| 86 | }, |
||
| 87 | ['locator.locators.magento'] |
||
| 88 | ); |
||
| 89 | |||
| 90 | $resourceManager = $c->get('locator.resource_manager'); |
||
| 91 | |||
| 92 | array_map( |
||
| 93 | array($resourceManager, 'registerLocator'), |
||
| 94 | $c->getByTag('locator.locators.magento') |
||
| 95 | ); |
||
| 96 | }); |
||
| 97 | } |
||
| 98 | } |
||
| 99 |