| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 21 |
| 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 |
||
| 27 | public function testDebugVariable() |
||
| 28 | { |
||
| 29 | $view = new DebugView(); |
||
| 30 | $this->assertEquals( |
||
| 31 | <<<EOS |
||
| 32 | <div style="background-color: white; text-align: left;"> |
||
| 33 | <hr> |
||
| 34 | <h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span> |
||
| 35 | </h3> |
||
| 36 | <pre style="font-family: Courier new, serif">string</pre> |
||
| 37 | </div> |
||
| 38 | EOS |
||
| 39 | , |
||
| 40 | $view->debugVariable('string', $this->caller) |
||
| 41 | ); |
||
| 42 | |||
| 43 | $this->assertEquals( |
||
| 44 | <<<EOS |
||
| 45 | <div style="background-color: white; text-align: left;"> |
||
| 46 | <hr> |
||
| 47 | <h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span> |
||
| 48 | </h3> |
||
| 49 | <ul> |
||
| 50 | <li>key = <pre style="font-family: Courier new, serif">value</pre> |
||
| 51 | </li> |
||
| 52 | <li>another = <pre style="font-family: Courier new, serif">text</pre> |
||
| 53 | </li> |
||
| 54 | </ul> |
||
| 55 | </div> |
||
| 56 | EOS |
||
| 57 | , |
||
| 58 | $view->debugVariable([ 'key' => 'value', 'another' => 'text' ], $this->caller) |
||
| 59 | ); |
||
| 60 | |||
| 61 | $this->assertEquals( |
||
| 62 | <<<EOS |
||
| 63 | <div style="background-color: white; text-align: left;"> |
||
| 64 | <hr> |
||
| 65 | <h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span> |
||
| 66 | </h3> |
||
| 67 | SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug::debug() custom content</div> |
||
| 68 | EOS |
||
| 69 | , |
||
| 70 | $view->debugVariable(new ObjectWithDebug(), $this->caller) |
||
| 71 | ); |
||
| 72 | |||
| 73 | $this->assertEquals( |
||
| 74 | <<<EOS |
||
| 75 | <div style="background-color: white; text-align: left;"> |
||
| 76 | <hr> |
||
| 77 | <h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span> |
||
| 78 | </h3> |
||
| 79 | <pre style="font-family: Courier new, serif">SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug</pre> |
||
| 80 | </div> |
||
| 81 | EOS |
||
| 82 | |||
| 83 | , |
||
| 84 | $view->debugVariable(ObjectWithDebug::class, $this->caller) |
||
| 85 | ); |
||
| 88 |