| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 104 | public function testConsolidateSubnetsVerboseWithMaxRules() |
||
| 105 | { |
||
| 106 | $initialIPs = [ |
||
| 107 | '10.10.10.0', |
||
| 108 | '10.10.10.1', |
||
| 109 | '10.10.10.2', |
||
| 110 | '100.10.10.0', |
||
| 111 | '100.10.10.1', |
||
| 112 | '100.10.10.2', |
||
| 113 | '100.10.10.3', |
||
| 114 | '100.10.10.4', |
||
| 115 | '100.10.10.5', |
||
| 116 | ]; |
||
| 117 | $initialSubnets = [ |
||
| 118 | '10.10.10.0/32', |
||
| 119 | '10.10.10.1/32', |
||
| 120 | '10.10.10.2/32', |
||
| 121 | '100.10.10.0/32', |
||
| 122 | '100.10.10.1/32', |
||
| 123 | '100.10.10.2/32', |
||
| 124 | '100.10.10.3/32', |
||
| 125 | '100.10.10.4/31', |
||
| 126 | ]; |
||
| 127 | |||
| 128 | $this->assertEquals( |
||
| 129 | [ |
||
| 130 | 'consolidated_subnets' => ['10.10.10.0/31', '10.10.10.2/32', '100.10.10.0/30', '100.10.10.4/31'], |
||
| 131 | 'initial_IPs' => $initialIPs, |
||
| 132 | 'total_IPs' => $initialIPs |
||
| 133 | ], |
||
| 134 | SubMuncher::consolidate_subnets_verbose($initialSubnets, 4) |
||
| 135 | ); |
||
| 136 | $this->assertEquals( |
||
| 137 | [ |
||
| 138 | 'consolidated_subnets' => ['10.10.10.0/30', '100.10.10.0/30', '100.10.10.4/31'], |
||
| 139 | 'initial_IPs' => $initialIPs, |
||
| 140 | 'total_IPs' => [ |
||
| 141 | '10.10.10.0', |
||
| 142 | '10.10.10.1', |
||
| 143 | '10.10.10.2', |
||
| 144 | '10.10.10.3', |
||
| 145 | '100.10.10.0', |
||
| 146 | '100.10.10.1', |
||
| 147 | '100.10.10.2', |
||
| 148 | '100.10.10.3', |
||
| 149 | '100.10.10.4', |
||
| 150 | '100.10.10.5', |
||
| 151 | ] |
||
| 152 | ], |
||
| 153 | SubMuncher::consolidate_subnets_verbose($initialSubnets, 3) |
||
| 154 | ); |
||
| 155 | } |
||
| 156 | } |
||
| 157 |