Conditions | 13 |
Paths | 912 |
Total Lines | 63 |
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 |
||
13 | public function load(array $configs, ContainerBuilder $container) |
||
14 | { |
||
15 | $loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__) . '/Resources/config')); |
||
16 | $loader->load('console.yml'); |
||
17 | $loader->load('service.yml'); |
||
18 | |||
19 | $configuration = $this->getConfiguration($configs, $container); |
||
20 | $config = $this->processConfiguration($configuration, $configs); |
||
21 | |||
22 | $container->setParameter('sapient.sealing_public_keys', $config['sealing_public_keys']); |
||
23 | $container->setParameter('sapient.verifying_public_keys', $config['verifying_public_keys']); |
||
24 | |||
25 | if ($config['seal']['enabled']) { |
||
26 | $loader->load('seal.yml'); |
||
27 | |||
28 | $container->setParameter('sapient.seal.public', $config['seal']['public']); |
||
29 | $container->setParameter('sapient.seal.private', $config['seal']['private']); |
||
30 | } |
||
31 | |||
32 | if ($config['sign']['enabled']) { |
||
33 | $loader->load('sign.yml'); |
||
34 | |||
35 | $container->setParameter('sapient.sign.public', $config['sign']['public']); |
||
36 | $container->setParameter('sapient.sign.private', $config['sign']['private']); |
||
37 | $container->setParameter('sapient.sign.host', $config['sign']['host']); |
||
38 | } |
||
39 | |||
40 | if ($config['unseal_request']) { |
||
41 | $loader->load('unseal_request.yml'); |
||
42 | } |
||
43 | |||
44 | if ($config['verify_request']) { |
||
45 | $loader->load('verify_request.yml'); |
||
46 | } |
||
47 | |||
48 | if ($config['guzzle_middleware']['enabled']) { |
||
49 | if ($config['guzzle_middleware']['verify']) { |
||
50 | $loader->load('guzzle_middleware/verify_response.yml'); |
||
51 | } |
||
52 | |||
53 | if ($config['guzzle_middleware']['unseal']) { |
||
54 | $loader->load('guzzle_middleware/unseal_response.yml'); |
||
55 | } |
||
56 | |||
57 | if ($config['guzzle_middleware']['requester_host']) { |
||
58 | $container->setParameter('sapient.guzzle_middleware.requester_host', $config['guzzle_middleware']['requester_host']); |
||
59 | $loader->load('guzzle_middleware/requester_header.yml'); |
||
60 | } |
||
61 | |||
62 | if ($config['guzzle_middleware']['sign_request']) { |
||
63 | if (!$config['sign']['enabled']) { |
||
64 | throw new \LogicException('You must enable "sign" option before using "sign_request" feature.'); |
||
65 | } |
||
66 | |||
67 | $loader->load('guzzle_middleware/sign_request.yml'); |
||
68 | } |
||
69 | |||
70 | if ($config['guzzle_middleware']['seal_request']) { |
||
71 | if (!$config['seal']['enabled']) { |
||
72 | throw new \LogicException('You must enable "seal" option before using "sign_request" feature.'); |
||
73 | } |
||
74 | |||
75 | $loader->load('guzzle_middleware/seal_request.yml'); |
||
76 | } |
||
80 |