| Conditions | 1 |
| Total Lines | 55 |
| 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 declare(strict_types=1); |
||
| 18 | public function testGetGettersAndSetters() |
||
| 19 | { |
||
| 20 | $testClass = new class () |
||
| 21 | { |
||
| 22 | use UsesPHPMetaDataTrait; |
||
| 23 | |||
| 24 | protected static function setCustomRepositoryClass(ClassMetadataBuilder $builder) |
||
|
|
|||
| 25 | { |
||
| 26 | // TODO: Implement setCustomRepositoryClass() method. |
||
| 27 | } |
||
| 28 | |||
| 29 | public function getThis() |
||
| 30 | { |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getThat() |
||
| 34 | { |
||
| 35 | } |
||
| 36 | |||
| 37 | public function setThis() |
||
| 38 | { |
||
| 39 | } |
||
| 40 | |||
| 41 | public function setThat() |
||
| 42 | { |
||
| 43 | } |
||
| 44 | |||
| 45 | private function getSomething() |
||
| 46 | { |
||
| 47 | } |
||
| 48 | |||
| 49 | private function setSomething() |
||
| 50 | { |
||
| 51 | } |
||
| 52 | |||
| 53 | protected function getSomethingElse() |
||
| 54 | { |
||
| 55 | } |
||
| 56 | |||
| 57 | protected function setSomethingElse() |
||
| 58 | { |
||
| 59 | } |
||
| 60 | }; |
||
| 61 | $expected = [ |
||
| 62 | 'getThis', |
||
| 63 | 'getThat', |
||
| 64 | ]; |
||
| 65 | $actual = $testClass->getGetters(); |
||
| 66 | $this->assertSame($expected, $actual); |
||
| 67 | $expected = [ |
||
| 68 | 'setThis', |
||
| 69 | 'setThat', |
||
| 70 | ]; |
||
| 71 | $actual = $testClass->getSetters(); |
||
| 72 | $this->assertSame($expected, $actual); |
||
| 73 | } |
||
| 75 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.