Conditions | 13 |
Paths | 1 |
Total Lines | 68 |
Code Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
24 | public function configureOptions(OptionsResolver $resolver) |
||
25 | { |
||
26 | $resolver |
||
27 | ->setDefaults([ |
||
28 | 'use_sandbox' => false, |
||
29 | 'httplug.client' => function () { |
||
30 | if (class_exists('\Http\Discovery\HttpClientDiscovery')) { |
||
31 | return \Http\Discovery\HttpClientDiscovery::find(); |
||
32 | } |
||
33 | |||
34 | if (class_exists('\Http\Adapter\Guzzle6\Client')) { |
||
35 | return new \Http\Adapter\Guzzle6\Client(); |
||
36 | } |
||
37 | |||
38 | if (class_exists('\Http\Adapter\Guzzle5\Client')) { |
||
39 | return new \Http\Adapter\Guzzle5\Client(); |
||
40 | } |
||
41 | |||
42 | if (class_exists('\Http\Client\Socket\Client')) { |
||
43 | return new \Http\Client\Socket\Client(); |
||
44 | } |
||
45 | |||
46 | if (class_exists('\Http\Client\Curl\Client')) { |
||
47 | return new \Http\Client\Curl\Client(); |
||
48 | } |
||
49 | |||
50 | if (class_exists('Http\Adapter\Buzz\Client')) { |
||
51 | return new \Http\Adapter\Buzz\Client(); |
||
52 | } |
||
53 | |||
54 | throw new \LogicException('The httplug.client could not be guessed. Install one of the following packages: php-http/guzzle6-adapter. You can also overwrite the config option with your implementation.'); |
||
55 | }, |
||
56 | 'httplug.message_factory' => function () { |
||
57 | if (class_exists('\Http\Discovery\MessageFactoryDiscovery')) { |
||
58 | return \Http\Discovery\MessageFactoryDiscovery::find(); |
||
59 | } |
||
60 | |||
61 | if (class_exists('\Zend\Diactoros\Request')) { |
||
62 | return new DiactorosMessageFactory(); |
||
63 | } |
||
64 | |||
65 | if (class_exists('\GuzzleHttp\Psr7\Request')) { |
||
66 | return new GuzzleMessageFactory(); |
||
67 | } |
||
68 | |||
69 | throw new \LogicException('The httplug.message_factory could not be guessed. Install one of the following packages: php-http/guzzle6-adapter. You can also overwrite the config option with your implementation.'); |
||
70 | }, |
||
71 | 'httplug.stream_factory' => function () { |
||
72 | if (class_exists('\Http\Discovery\StreamFactoryDiscovery')) { |
||
73 | return \Http\Discovery\StreamFactoryDiscovery::find(); |
||
74 | } |
||
75 | |||
76 | if (class_exists('\Zend\Diactoros\Stream')) { |
||
77 | return new DiactorosStreamFactory(); |
||
78 | } |
||
79 | |||
80 | if (function_exists('\GuzzleHttp\Psr7\stream_for')) { |
||
81 | return new GuzzleStreamFactory(); |
||
82 | } |
||
83 | |||
84 | throw new \LogicException('The httplug.stream_factory could not be guessed. Install one of the following packages: php-http/guzzle6-adapter. You can also overwrite the config option with your implementation.'); |
||
85 | }, |
||
86 | ]) |
||
87 | ->setAllowedTypes('use_sandbox', 'bool') |
||
88 | ->setAllowedTypes('httplug.client', '\Http\Client\HttpClient') |
||
89 | ->setAllowedTypes('httplug.message_factory', '\Http\Message\MessageFactory') |
||
90 | ->setAllowedTypes('httplug.stream_factory', '\Http\Message\StreamFactory'); |
||
91 | } |
||
92 | |||
125 |