| Conditions | 11 |
| Paths | 192 |
| Total Lines | 46 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 55 | public function load(array $config, ContainerBuilder $container) |
||
| 56 | { |
||
| 57 | $config = $this->processConfiguration($this->getBundleConfiguration(), $config); |
||
| 58 | $loader = new YamlFileLoader($container, new FileLocator($this->getConfigDir())); |
||
| 59 | |||
| 60 | if (empty($config['resources'])) { |
||
| 61 | $config['resources'] = array(); |
||
| 62 | } |
||
| 63 | |||
| 64 | if (isset($config['driver'])) { |
||
| 65 | $this->registerResources($this->applicationName, $config['driver'], $config['resources'], $container); |
||
| 66 | } |
||
| 67 | |||
| 68 | $interfaces = array(); |
||
| 69 | |||
| 70 | foreach($config['resources'] as $model => $resource) { |
||
| 71 | foreach($resource['classes'] as $key => $class) { |
||
| 72 | if ($key === 'interface') { |
||
| 73 | $name = sprintf('%s.%s.%s.class', $this->applicationName, $key, $model); |
||
| 74 | $container->setParameter($name, $class); |
||
| 75 | |||
| 76 | $interfaces[$class] = sprintf('%s.%s.%s.class', $this->applicationName, 'model', $model); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | $container->setParameter($this->getAlias() . '_interfaces', $interfaces); |
||
| 82 | |||
| 83 | foreach($config['resources'] as $model => $resource) { |
||
| 84 | foreach($resource['classes'] as $key => $class) { |
||
| 85 | if ($key === 'provider') { |
||
| 86 | $name = sprintf('%s.%s.%s.class', $this->applicationName, $key, $model); |
||
| 87 | $container->setParameter($name, $class); |
||
| 88 | $this->addProvider($container, $class, $model); |
||
| 89 | } |
||
| 90 | } |
||
| 91 | } |
||
| 92 | |||
| 93 | foreach ($this->configFiles as $configFile) { |
||
| 94 | if (file_exists(sprintf('%s/%s', $this->getConfigDir(), $configFile))) { |
||
| 95 | $loader->load($configFile); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | return $config; |
||
| 100 | } |
||
| 101 | |||
| 132 |