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