Conditions | 13 |
Paths | 1 |
Total Lines | 72 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 | 'event_dispatcher' => function () { |
||
30 | return new EventDispatcher(); |
||
31 | }, |
||
32 | 'httplug.client' => function () { |
||
33 | if (class_exists('\Http\Discovery\HttpClientDiscovery')) { |
||
34 | return \Http\Discovery\HttpClientDiscovery::find(); |
||
35 | } |
||
36 | |||
37 | if (class_exists('\Http\Adapter\Guzzle6\Client')) { |
||
38 | return new \Http\Adapter\Guzzle6\Client(); |
||
39 | } |
||
40 | |||
41 | if (class_exists('\Http\Adapter\Guzzle5\Client')) { |
||
42 | return new \Http\Adapter\Guzzle5\Client(); |
||
43 | } |
||
44 | |||
45 | if (class_exists('\Http\Client\Socket\Client')) { |
||
46 | return new \Http\Client\Socket\Client(); |
||
47 | } |
||
48 | |||
49 | if (class_exists('\Http\Client\Curl\Client')) { |
||
50 | return new \Http\Client\Curl\Client(); |
||
51 | } |
||
52 | |||
53 | if (class_exists('\Http\Adapter\Buzz\Client')) { |
||
54 | return new \Http\Adapter\Buzz\Client(); |
||
55 | } |
||
56 | |||
57 | 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.'); |
||
58 | }, |
||
59 | 'httplug.message_factory' => function () { |
||
60 | if (class_exists('\Http\Discovery\MessageFactoryDiscovery')) { |
||
61 | return \Http\Discovery\MessageFactoryDiscovery::find(); |
||
62 | } |
||
63 | |||
64 | if (class_exists('\Zend\Diactoros\Request')) { |
||
65 | return new DiactorosMessageFactory(); |
||
66 | } |
||
67 | |||
68 | if (class_exists('\GuzzleHttp\Psr7\Request')) { |
||
69 | return new GuzzleMessageFactory(); |
||
70 | } |
||
71 | |||
72 | 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.'); |
||
73 | }, |
||
74 | 'httplug.stream_factory' => function () { |
||
75 | if (class_exists('\Http\Discovery\StreamFactoryDiscovery')) { |
||
76 | return \Http\Discovery\StreamFactoryDiscovery::find(); |
||
77 | } |
||
78 | |||
79 | if (class_exists('\Zend\Diactoros\Stream')) { |
||
80 | return new DiactorosStreamFactory(); |
||
81 | } |
||
82 | |||
83 | if (function_exists('\GuzzleHttp\Psr7\stream_for')) { |
||
84 | return new GuzzleStreamFactory(); |
||
85 | } |
||
86 | |||
87 | 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.'); |
||
88 | }, |
||
89 | ]) |
||
90 | ->setAllowedTypes('use_sandbox', 'bool') |
||
91 | ->setAllowedTypes('event_dispatcher', '\Symfony\Component\EventDispatcher\EventDispatcher') |
||
92 | ->setAllowedTypes('httplug.client', '\Http\Client\HttpClient') |
||
93 | ->setAllowedTypes('httplug.message_factory', '\Http\Message\MessageFactory') |
||
94 | ->setAllowedTypes('httplug.stream_factory', '\Http\Message\StreamFactory'); |
||
95 | } |
||
96 | |||
121 |