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