| Conditions | 12 |
| Paths | 75 |
| Total Lines | 37 |
| Code Lines | 20 |
| 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 |
||
| 59 | private function loadGuzzleMiddlewareConfiguration(array $config, YamlFileLoader $loader, ContainerBuilder $container): void |
||
| 60 | { |
||
| 61 | if ($config['guzzle_middleware']['enabled']) { |
||
| 62 | if ($config['guzzle_middleware']['verify']) { |
||
| 63 | $loader->load('guzzle_middleware/verify_response.yml'); |
||
| 64 | } |
||
| 65 | |||
| 66 | if ($config['guzzle_middleware']['unseal']) { |
||
| 67 | if (!$config['seal']['enabled'] || !$config['seal']['private']) { |
||
| 68 | throw new ConfigurationRequiredException('You must enable "seal" option and configure a "seal.private" key before using "guzzle_middleware.unseal" feature.'); |
||
| 69 | } |
||
| 70 | |||
| 71 | $loader->load('guzzle_middleware/unseal_response.yml'); |
||
| 72 | } |
||
| 73 | |||
| 74 | if ($config['guzzle_middleware']['requester_host']) { |
||
| 75 | $container->setParameter('sapient.guzzle_middleware.requester_host', $config['guzzle_middleware']['requester_host']); |
||
| 76 | $loader->load('guzzle_middleware/requester_header.yml'); |
||
| 77 | } |
||
| 78 | |||
| 79 | if ($config['guzzle_middleware']['sign_request']) { |
||
| 80 | if (!$config['sign']['enabled']) { |
||
| 81 | throw new ConfigurationRequiredException('You must enable "sign" option and configure a "sign.private" key before using "guzzle_middleware.sign_request" feature.'); |
||
| 82 | } |
||
| 83 | |||
| 84 | $loader->load('guzzle_middleware/sign_request.yml'); |
||
| 85 | } |
||
| 86 | |||
| 87 | if ($config['guzzle_middleware']['seal_request']) { |
||
| 88 | if (!$config['seal']['enabled']) { |
||
| 89 | throw new ConfigurationRequiredException('You must enable "seal" option and configure a "seal.private" key before using "guzzle_middleware.seal_request" feature.'); |
||
| 90 | } |
||
| 91 | |||
| 92 | if (!$config['guzzle_middleware']['sign_request']) { |
||
| 93 | throw new ConfigurationRequiredException('You must enable "guzzle_middleware.sign_request" option before using "guzzle_middleware.seal_request" feature.'); |
||
| 94 | } |
||
| 95 | $loader->load('guzzle_middleware/seal_request.yml'); |
||
| 96 | } |
||
| 118 |