| Conditions | 4 |
| Paths | 6 |
| Total Lines | 51 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 30 | public function process(ContainerBuilder $container) |
||
| 31 | { |
||
| 32 | // If it's inside vendor library or running as graviton base. |
||
| 33 | $rootDir = $container->getParameter('kernel.root_dir'); |
||
| 34 | |||
| 35 | if (strpos($rootDir, 'vendor/graviton')) { |
||
| 36 | $dirs = [ |
||
| 37 | $rootDir.'/../..' |
||
| 38 | ]; |
||
| 39 | } else { |
||
| 40 | $dirs = [ |
||
| 41 | __DIR__ . '/../../../..', |
||
| 42 | $rootDir.'/../vendor/graviton' |
||
| 43 | ]; |
||
| 44 | } |
||
| 45 | |||
| 46 | $dynamicBundleDir = $container->getParameter('graviton.generator.dynamicbundle.dir'); |
||
| 47 | if (!empty($dynamicBundleDir)) { |
||
| 48 | // if this is not an absolute dir, make it relative to the base dir |
||
| 49 | if (substr($dynamicBundleDir, 0, 1) !== '/') { |
||
| 50 | $dynamicBundleDir = $container->getParameter('kernel.root_dir').'/../'.$dynamicBundleDir; |
||
| 51 | } |
||
| 52 | |||
| 53 | $dirs[] = $dynamicBundleDir; |
||
| 54 | } else { |
||
| 55 | // default dynamic bundle dir is withing our ./src |
||
| 56 | $dynamicBundleDir = __DIR__.'/../../../../GravitonDyn'; |
||
| 57 | } |
||
| 58 | |||
| 59 | $documentMap = new DocumentMap( |
||
| 60 | (new Finder()) |
||
| 61 | ->in($dirs) |
||
| 62 | ->path('Resources/config/doctrine') |
||
| 63 | ->name('*.mongodb.xml'), |
||
| 64 | (new Finder()) |
||
| 65 | ->in($dirs) |
||
| 66 | ->path('Resources/config/serializer') |
||
| 67 | ->name('*.xml'), |
||
| 68 | (new Finder()) |
||
| 69 | ->in($dirs) |
||
| 70 | ->path('Resources/config') |
||
| 71 | ->name('validation.xml'), |
||
| 72 | (new Finder()) |
||
| 73 | ->in($dirs) |
||
| 74 | ->path('Resources/config/schema') |
||
| 75 | ->name('*.json') |
||
| 76 | ); |
||
| 77 | |||
| 78 | $container->set('graviton.document.map', $documentMap); |
||
| 79 | $container->setParameter('graviton.generator.dynamicbundle.dir', $dynamicBundleDir); |
||
| 80 | } |
||
| 81 | } |
||
| 82 |