Conditions | 8 |
Paths | 10 |
Total Lines | 60 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 3 |
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 |
||
28 | public function load(array $configs, ContainerBuilder $container) |
||
29 | { |
||
30 | $config = $this->processConfiguration(new Configuration(), $configs); |
||
31 | |||
32 | $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/services')); |
||
33 | $loader->load('server.xml'); |
||
34 | $loader->load('extensions.xml'); |
||
35 | $loader->load('empty.xml'); |
||
36 | $loader->load('orm.xml'); |
||
37 | |||
38 | if (!$container->hasDefinition('majora.oauth.server')) { |
||
39 | return; |
||
40 | } |
||
41 | |||
42 | // token generator |
||
43 | $randomGeneratorDefinition = $container->getDefinition('majora.oauth.random_generator'); |
||
44 | $randomGeneratorDefinition->replaceArgument(0, $config['secret']); |
||
45 | |||
46 | // server |
||
47 | $serverDefinition = $container->getDefinition('majora.oauth.server'); |
||
48 | $serverDefinition->replaceArgument(4, array( |
||
49 | 'access_token_class' => $config['access_token']['class'], |
||
50 | 'access_token_ttl' => $config['access_token']['ttl'], |
||
51 | 'refresh_token_class' => $config['refresh_token']['class'], |
||
52 | 'refresh_token_ttl' => $config['refresh_token']['ttl'], |
||
53 | )); |
||
54 | |||
55 | // aliases generation |
||
56 | foreach (array('access_token', 'refresh_token', 'application', 'account') as $entity) { |
||
57 | foreach (array('loader', 'repository') as $serviceAlias) { |
||
58 | foreach ($config[$entity][$serviceAlias] as $driver => $parameters) { |
||
59 | |||
60 | // given service id or build one from registered strategies |
||
61 | $serviceId = $driver == 'id' ? |
||
62 | $parameters : |
||
63 | sprintf('majora.oauth.%s.%s_%s', $entity, $driver, $serviceAlias) |
||
64 | ; |
||
65 | |||
66 | // publish given service |
||
67 | $container->setAlias( |
||
68 | sprintf('majora.oauth.%s.%s', $entity, $serviceAlias), |
||
69 | $serviceId |
||
70 | ); |
||
71 | |||
72 | // register parameters under driver if given |
||
73 | // |
||
74 | // !! implements here a better strategy !! |
||
75 | // |
||
76 | if (is_array($parameters)) { |
||
77 | foreach ($parameters as $key => $value) { |
||
78 | $container->setParameter( |
||
79 | sprintf('majora.oauth.%s.%s_%s.%s', $entity, $driver, $serviceAlias, $key), |
||
80 | $value |
||
81 | ); |
||
82 | } |
||
83 | } |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 | } |
||
88 | } |
||
89 |