Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 41 |
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 |
||
25 | private function phpFilesProvider(): array |
||
26 | { |
||
27 | return [ |
||
28 | ['boolean parameter', true], |
||
29 | ['string parameter', 'value of param 1'], |
||
30 | ['NAN parameter', 'NAN'], |
||
31 | ['float parameter', 1.0000001], |
||
32 | ['int parameter', 123], |
||
33 | ['long int parameter', 123_000], |
||
|
|||
34 | ['array parameter', [ |
||
35 | 'changed value' => 'from root config', |
||
36 | 'first-vendor/first-package' => true, |
||
37 | 'first-vendor/second-package' => true, |
||
38 | 'second-vendor/first-package' => true, |
||
39 | 'second-vendor/second-package' => true, |
||
40 | [[[[[]]]]], |
||
41 | ]], |
||
42 | ['array parameter with UnsetArrayValue', [ |
||
43 | 'first-vendor/second-package' => true, |
||
44 | 'second-vendor/first-package' => true, |
||
45 | 'second-vendor/second-package' => true, |
||
46 | ]], |
||
47 | ['array parameter with ReplaceArrayValue', ['replace']], |
||
48 | ['array parameter with RemoveArrayKeys', [ |
||
49 | 'first-vendor/first-package', |
||
50 | 'first-vendor/second-package', |
||
51 | 'second-vendor/first-package', |
||
52 | 'second-vendor/second-package', |
||
53 | 'root value', |
||
54 | ]], |
||
55 | [ |
||
56 | 'callable parameter', |
||
57 | new LiterallyCallback(function () { |
||
58 | return 'I am callable'; |
||
59 | }), |
||
60 | ], |
||
61 | [ |
||
62 | 'static callable parameter', |
||
63 | new LiterallyCallback(static function () { |
||
64 | return 'I am callable'; |
||
65 | }), |
||
66 | ], |
||
67 | ['object parameter', new stdClass()], |
||
68 | /** |
||
69 | * Test for subpackages parameters |
||
70 | */ |
||
71 | ['first-vendor/first-package', true], |
||
72 | ['first-vendor/second-package', true], |
||
73 | ['first-dev-vendor/first-package', true], |
||
74 | ['first-dev-vendor/second-package', true], |
||
75 | ['second-vendor/first-package', true], |
||
76 | ['second-vendor/second-package', true], |
||
77 | ['second-dev-vendor/first-package', true], |
||
78 | ['second-dev-vendor/second-package', true], |
||
79 | ['constant_based_parameter', 'a constant value defined in config/constants.php'], |
||
80 | ['constant_from_vendor', 'a constant value defined in first-dev-vendor/second-package'], |
||
81 | ]; |
||
98 |