Conditions | 1 |
Paths | 1 |
Total Lines | 131 |
Code Lines | 85 |
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 trustedDataProvider(): array |
||
25 | { |
||
26 | return [ |
||
27 | 'xForwardLevel1' => [ |
||
28 | ['x-forwarded-for' => ['9.9.9.9', '5.5.5.5', '2.2.2.2']], |
||
29 | ['REMOTE_ADDR' => '127.0.0.1'], |
||
30 | [ |
||
31 | ['hosts' => ['8.8.8.8', '127.0.0.1'], 'ipHeaders' => ['x-forwarded-for']] |
||
32 | ], |
||
33 | '2.2.2.2', |
||
34 | ], |
||
35 | 'xForwardLevel2' => [ |
||
36 | ['x-forwarded-for' => ['9.9.9.9', '5.5.5.5', '2.2.2.2']], |
||
37 | ['REMOTE_ADDR' => '127.0.0.1'], |
||
38 | [ |
||
39 | ['hosts' => ['8.8.8.8', '127.0.0.1', '2.2.2.2'], 'ipHeaders' => ['x-forwarded-for']], |
||
40 | ], |
||
41 | '5.5.5.5', |
||
42 | ], |
||
43 | 'rfc7239Level1' => [ |
||
44 | ['forwarded' => ['for=9.9.9.9', 'for=5.5.5.5', 'for=2.2.2.2']], |
||
45 | ['REMOTE_ADDR' => '127.0.0.1'], |
||
46 | [ |
||
47 | [ |
||
48 | 'hosts' => ['8.8.8.8', '127.0.0.1'], |
||
49 | 'ipHeaders' => [[TrustedHostsNetworkResolver::IP_HEADER_TYPE_RFC7239, 'forwarded']], |
||
50 | ] |
||
51 | ], |
||
52 | '2.2.2.2', |
||
53 | ], |
||
54 | 'rfc7239Level2' => [ |
||
55 | ['forwarded' => ['for=9.9.9.9', 'for=5.5.5.5', 'for=2.2.2.2']], |
||
56 | ['REMOTE_ADDR' => '127.0.0.1'], |
||
57 | [ |
||
58 | [ |
||
59 | 'hosts' => ['8.8.8.8', '127.0.0.1', '2.2.2.2'], |
||
60 | 'ipHeaders' => [[TrustedHostsNetworkResolver::IP_HEADER_TYPE_RFC7239, 'forwarded']], |
||
61 | ], |
||
62 | |||
63 | ], |
||
64 | '5.5.5.5', |
||
65 | ], |
||
66 | 'rfc7239Level2HostAndProtocol' => [ |
||
67 | ['forwarded' => ['for=9.9.9.9', 'proto=https;for=5.5.5.5;host=test', 'for=2.2.2.2']], |
||
68 | ['REMOTE_ADDR' => '127.0.0.1'], |
||
69 | [ |
||
70 | [ |
||
71 | 'hosts' => ['8.8.8.8', '127.0.0.1', '2.2.2.2'], |
||
72 | 'ipHeaders' => [[TrustedHostsNetworkResolver::IP_HEADER_TYPE_RFC7239, 'forwarded']], |
||
73 | 'hostHeaders' => ['forwarded'], |
||
74 | 'protocolHeaders' => ['forwarded' => ['http' => 'http', 'https' => 'https']], |
||
75 | ], |
||
76 | ], |
||
77 | '5.5.5.5', |
||
78 | 'test', |
||
79 | 'https', |
||
80 | ], |
||
81 | 'rfc7239Level2HostAndProtocolAndUrl' => [ |
||
82 | [ |
||
83 | 'forwarded' => ['for=9.9.9.9', 'proto=https;for=5.5.5.5;host=test', 'for=2.2.2.2'], |
||
84 | 'x-rewrite-url' => ['/test?test=test'], |
||
85 | ], |
||
86 | ['REMOTE_ADDR' => '127.0.0.1'], |
||
87 | [ |
||
88 | [ |
||
89 | 'hosts' => ['8.8.8.8', '127.0.0.1', '2.2.2.2'], |
||
90 | 'ipHeaders' => [[TrustedHostsNetworkResolver::IP_HEADER_TYPE_RFC7239, 'forwarded']], |
||
91 | 'hostHeaders' => ['forwarded'], |
||
92 | 'protocolHeaders' => ['forwarded' => ['http' => 'http', 'https' => 'https']], |
||
93 | 'urlHeaders' => ['x-rewrite-url'], |
||
94 | ], |
||
95 | ], |
||
96 | '5.5.5.5', |
||
97 | 'test', |
||
98 | 'https', |
||
99 | '/test', |
||
100 | 'test=test', |
||
101 | ], |
||
102 | 'rfc7239Level2AnotherHost&AnotherProtocol&Url' => [ |
||
103 | [ |
||
104 | 'forwarded' => ['for=9.9.9.9', 'proto=https;for=5.5.5.5;host=test', 'for=2.2.2.2'], |
||
105 | 'x-rewrite-url' => ['/test?test=test'], |
||
106 | 'x-forwarded-host' => ['test.another'], |
||
107 | 'x-forwarded-proto' => ['on'] |
||
108 | ], |
||
109 | ['REMOTE_ADDR' => '127.0.0.1'], |
||
110 | [ |
||
111 | [ |
||
112 | 'hosts' => ['8.8.8.8', '127.0.0.1', '2.2.2.2'], |
||
113 | 'ipHeaders' => [[TrustedHostsNetworkResolver::IP_HEADER_TYPE_RFC7239, 'forwarded']], |
||
114 | 'hostHeaders' => ['x-forwarded-host', 'forwarded'], |
||
115 | 'protocolHeaders' => [ |
||
116 | 'x-forwarded-proto' => ['http' => 'http', 'httpsss' => 'on'], |
||
117 | 'forwarded' => ['http' => 'http', 'https' => 'https'] |
||
118 | ], |
||
119 | 'urlHeaders' => ['x-rewrite-url'], |
||
120 | ], |
||
121 | ], |
||
122 | '5.5.5.5', |
||
123 | 'test.another', |
||
124 | 'httpsss', |
||
125 | '/test', |
||
126 | 'test=test', |
||
127 | ], |
||
128 | 'rfc7239Level2AnotherHost&AnotherProtocol&Url&Port' => [ |
||
129 | [ |
||
130 | 'forwarded' => ['for=9.9.9.9', 'proto=https;for="5.5.5.5:123";host=test', 'for=2.2.2.2'], |
||
131 | 'x-rewrite-url' => ['/test?test=test'], |
||
132 | 'x-forwarded-host' => ['test.another'], |
||
133 | 'x-forwarded-proto' => ['on'] |
||
134 | ], |
||
135 | ['REMOTE_ADDR' => '127.0.0.1'], |
||
136 | [ |
||
137 | [ |
||
138 | 'hosts' => ['8.8.8.8', '127.0.0.1', '2.2.2.2'], |
||
139 | 'ipHeaders' => [[TrustedHostsNetworkResolver::IP_HEADER_TYPE_RFC7239, 'forwarded']], |
||
140 | 'hostHeaders' => ['x-forwarded-host', 'forwarded'], |
||
141 | 'protocolHeaders' => [ |
||
142 | 'x-forwarded-proto' => ['http' => 'http', 'httpsss' => 'on'], |
||
143 | 'forwarded' => ['http' => 'http', 'https' => 'https'] |
||
144 | ], |
||
145 | 'urlHeaders' => ['x-rewrite-url'], |
||
146 | 'portHeaders' => ['forwarded'], |
||
147 | ], |
||
148 | ], |
||
149 | '5.5.5.5', |
||
150 | 'test.another', |
||
151 | 'httpsss', |
||
152 | '/test', |
||
153 | 'test=test', |
||
154 | 123, |
||
155 | ], |
||
292 |