Conditions | 4 |
Paths | 4 |
Total Lines | 93 |
Code Lines | 43 |
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 |
||
47 | public function DataProviderHttpHandlerHandle() : Generator |
||
48 | { |
||
49 | foreach ($this->DataProviderHttpHandlerInstances() as $args) { |
||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | $implementation = $args[0]; |
||
54 | |||
55 | /** |
||
56 | * @var array<string, mixed[]> |
||
57 | */ |
||
58 | $postConstructionCalls = $args[1]; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | $basePath = $args[3]; |
||
64 | |||
65 | /** |
||
66 | * @var array<string, mixed[]> |
||
67 | */ |
||
68 | $config = $args[4]; |
||
69 | |||
70 | foreach ($this->DataProviderVerifyHandlerGood() as $testArgs) { |
||
71 | list($baseUrl, $config, $testArgs) = $this->prepDataProviderVerifyHandlerGoodArgs( |
||
72 | $config, |
||
73 | $testArgs |
||
74 | ); |
||
75 | |||
76 | if ( |
||
77 | ! isset($testArgs[0], $testArgs[1], $testArgs[2], $testArgs[3], $testArgs[4]) |
||
78 | ) { |
||
79 | throw new RuntimeException(sprintf( |
||
80 | 'Unsupported args derived from %s::prepDataProviderVerifyHandlerGoodArgs', |
||
81 | get_class($this) |
||
82 | )); |
||
83 | } |
||
84 | |||
85 | $baseUrl = (string) $baseUrl; |
||
86 | $config = (array) $config; |
||
87 | |||
88 | /** |
||
89 | * @var array |
||
90 | */ |
||
91 | $testArgs = $testArgs; |
||
92 | |||
93 | /** |
||
94 | * @var int |
||
95 | */ |
||
96 | $expectedStatus = $testArgs[2]; |
||
97 | |||
98 | /** |
||
99 | * @var string |
||
100 | */ |
||
101 | $expectedContent = $testArgs[3]; |
||
102 | |||
103 | /** |
||
104 | * @var array |
||
105 | */ |
||
106 | $requestArgs = $testArgs[4]; |
||
107 | |||
108 | $instance = Utilities::ObtainHttpHandlerInstanceMixedArgs( |
||
109 | $this, |
||
110 | $implementation, |
||
111 | $baseUrl, |
||
112 | $basePath, |
||
113 | $config |
||
114 | ); |
||
115 | Utilities::ConfigureFrameworkInstance($this, $instance, $postConstructionCalls); |
||
116 | |||
117 | $uri = (string) $requestArgs[0]; |
||
118 | $method = (string) ($requestArgs[1] ?? 'GET'); |
||
119 | $parameters = (array) ($requestArgs[2] ?? []); |
||
120 | $cookies = (array) ($requestArgs[3] ?? []); |
||
121 | $files = (array) ($requestArgs[4] ?? []); |
||
122 | $server = (array) ($requestArgs[5] ?? []); |
||
123 | |||
124 | /** |
||
125 | * @var string|resource|null |
||
126 | */ |
||
127 | $content = ($requestArgs[6] ?? null); |
||
128 | |||
129 | $request = Request::create( |
||
130 | $uri, |
||
131 | $method, |
||
132 | $parameters, |
||
133 | $cookies, |
||
134 | $files, |
||
135 | $server, |
||
136 | $content |
||
137 | ); |
||
138 | |||
139 | yield [$instance, $request, $expectedStatus, $expectedContent]; |
||
140 | } |
||
296 |