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