| Conditions | 1 |
| Paths | 1 |
| Total Lines | 124 |
| Code Lines | 82 |
| 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 |
||
| 21 | protected function main() |
||
| 22 | { |
||
| 23 | $this->setTemplate('xffdemo.tpl'); |
||
| 24 | |||
| 25 | // requestHasForwardedIp == false |
||
| 26 | // requestProxyData |
||
| 27 | // requestRealIp == proxy |
||
| 28 | // requestForwardedIp == xff header |
||
| 29 | // forwardedOrigin == top of the chain, assuming xff is trusted |
||
| 30 | |||
| 31 | |||
| 32 | $this->assign('demo2', [ |
||
| 33 | [ |
||
| 34 | 'trust' => true, |
||
| 35 | 'trustedlink' => true, |
||
| 36 | 'ip' => '172.16.0.164', |
||
| 37 | 'routable' => false, |
||
| 38 | |||
| 39 | ],[ |
||
| 40 | 'trust' => true, |
||
| 41 | 'ip' => '198.51.100.123', |
||
| 42 | 'routable' => true, |
||
| 43 | 'rdns' => 'trustedproxy.example.com', |
||
| 44 | |||
| 45 | ],[ |
||
| 46 | 'trust' => true, |
||
| 47 | 'ip' => '192.0.2.1', |
||
| 48 | 'routable' => true, |
||
| 49 | 'rdns' => 'client.users.example.org', |
||
| 50 | 'location' => [ |
||
| 51 | 'cityName' => 'San Francisco', |
||
| 52 | 'regionName' => 'California', |
||
| 53 | 'countryName' => 'United States' |
||
| 54 | ], |
||
| 55 | 'showlinks' => true |
||
| 56 | ] |
||
| 57 | ]); |
||
| 58 | |||
| 59 | $this->assign('demo3', [ |
||
| 60 | [ |
||
| 61 | 'trust' => true, |
||
| 62 | 'trustedlink' => true, |
||
| 63 | 'ip' => '172.16.0.164', |
||
| 64 | 'routable' => false, |
||
| 65 | |||
| 66 | ],[ |
||
| 67 | 'trust' => false, |
||
| 68 | 'ip' => '198.51.100.234', |
||
| 69 | 'routable' => true, |
||
| 70 | 'rdns' => 'sketchyproxy.example.com', |
||
| 71 | 'showlinks' => true |
||
| 72 | |||
| 73 | ],[ |
||
| 74 | 'trust' => false, |
||
| 75 | 'ip' => '192.0.2.1', |
||
| 76 | 'routable' => true, |
||
| 77 | 'rdns' => 'client.users.example.org', |
||
| 78 | 'location' => [ |
||
| 79 | 'cityName' => 'San Francisco', |
||
| 80 | 'regionName' => 'California', |
||
| 81 | 'countryName' => 'United States' |
||
| 82 | ], |
||
| 83 | 'showlinks' => true |
||
| 84 | ] |
||
| 85 | ]); |
||
| 86 | |||
| 87 | $this->assign('demo4', [ |
||
| 88 | [ |
||
| 89 | 'trust' => true, |
||
| 90 | 'trustedlink' => true, |
||
| 91 | 'ip' => '172.16.0.164', |
||
| 92 | 'routable' => false, |
||
| 93 | |||
| 94 | ],[ |
||
| 95 | 'trust' => true, |
||
| 96 | 'ip' => '198.51.100.123', |
||
| 97 | 'routable' => true, |
||
| 98 | 'rdns' => 'trustedproxy.example.com', |
||
| 99 | ],[ |
||
| 100 | 'trust' => false, |
||
| 101 | 'ip' => '198.51.100.234', |
||
| 102 | 'routable' => true, |
||
| 103 | 'rdns' => 'sketchyproxy.example.com', |
||
| 104 | 'showlinks' => true |
||
| 105 | ], [ |
||
| 106 | 'trust' => false, |
||
| 107 | 'trustedlink' => true, |
||
| 108 | 'ip' => '198.51.100.124', |
||
| 109 | 'routable' => true, |
||
| 110 | 'rdns' => 'trustedproxy2.example.com', |
||
| 111 | 'showlinks' => true |
||
| 112 | ],[ |
||
| 113 | 'trust' => false, |
||
| 114 | 'ip' => '192.0.2.1', |
||
| 115 | 'routable' => true, |
||
| 116 | 'rdns' => 'client.users.example.org', |
||
| 117 | 'location' => [ |
||
| 118 | 'cityName' => 'San Francisco', |
||
| 119 | 'regionName' => 'California', |
||
| 120 | 'countryName' => 'United States' |
||
| 121 | ], |
||
| 122 | 'showlinks' => true |
||
| 123 | ] |
||
| 124 | ]); |
||
| 125 | |||
| 126 | $this->assign('demo1', [ |
||
| 127 | [ |
||
| 128 | 'trust' => true, |
||
| 129 | 'trustedlink' => true, |
||
| 130 | 'ip' => '172.16.0.164', |
||
| 131 | 'routable' => false, |
||
| 132 | |||
| 133 | ], [ |
||
| 134 | 'trust' => true, |
||
| 135 | 'trustedlink' => true, |
||
| 136 | 'ip' => '192.0.2.1', |
||
| 137 | 'routable' => true, |
||
| 138 | 'rdns' => 'client.users.example.org', |
||
| 139 | 'location' => [ |
||
| 140 | 'cityName' => 'San Francisco', |
||
| 141 | 'regionName' => 'California', |
||
| 142 | 'countryName' => 'United States' |
||
| 143 | ], |
||
| 144 | 'showlinks' => true |
||
| 145 | ] |
||
| 149 |