| Conditions | 10 |
| Paths | 16 |
| Total Lines | 27 |
| Code Lines | 22 |
| 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 |
||
| 32 | public function testGetPanel(): void { |
||
| 33 | $result = $this->panel->getPanel(); |
||
| 34 | Assert::type("string", $result); |
||
| 35 | $r = new \SimpleXMLElement("<root>$result</root>"); |
||
| 36 | Assert::same(2, $r->count()); |
||
| 37 | $text = (string) $r->p; |
||
| 38 | Assert::same("Untranslated messages: 0, loaded resources 0", $text); |
||
| 39 | Assert::same("Resolved language", (string) $r->div->div->h1); |
||
| 40 | foreach($r->div->div->table->tr->children() as $i => $td) { |
||
| 41 | if($i === 0) { |
||
| 42 | Assert::same("ManualLocaleResolver", (string) $td); |
||
| 43 | } elseif($i === 1) { |
||
| 44 | Assert::same("en", (string) $td); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | foreach($r->children() as $i1 => $div) { |
||
| 48 | if($i1 === 1) { |
||
| 49 | Assert::same("Loaded resources", (string) $div->h1); |
||
| 50 | foreach($div->table->th as $i2 => $td) { |
||
| 51 | if($i2 === 0) { |
||
| 52 | Assert::same("Domain", (string) $td); |
||
| 53 | } elseif($i2 === 1) { |
||
| 54 | Assert::same("Filename", (string) $td); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | } elseif($i1 === 2) { |
||
| 58 | Assert::count(0, $div->children()); |
||
| 59 | } |
||
| 88 | ?> |