| Conditions | 1 |
| Paths | 1 |
| Total Lines | 75 |
| Code Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 7 | ||
| 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 |
||
| 12 | public function configProvider(): array |
||
| 13 | { |
||
| 14 | return [ |
||
| 15 | ['boolean parameter', true], |
||
| 16 | ['string parameter', 'value of param 1'], |
||
| 17 | ['NAN parameter', 'NAN'], |
||
| 18 | ['float parameter', 1.0000001], |
||
| 19 | ['int parameter', 123], |
||
| 20 | ['long int parameter', 123_000], |
||
|
|
|||
| 21 | ['array parameter', [ |
||
| 22 | 'changed value' => 'from root config', |
||
| 23 | 'first-vendor/first-package' => true, |
||
| 24 | 'first-vendor/second-package' => true, |
||
| 25 | 'second-vendor/first-package' => true, |
||
| 26 | 'second-vendor/second-package' => true, |
||
| 27 | [[[[[]]]]], |
||
| 28 | ]], |
||
| 29 | ['array parameter with UnsetArrayValue', [ |
||
| 30 | 'first-vendor/second-package' => true, |
||
| 31 | 'second-vendor/first-package' => true, |
||
| 32 | 'second-vendor/second-package' => true, |
||
| 33 | ]], |
||
| 34 | ['array parameter with ReplaceArrayValue', ['replace']], |
||
| 35 | ['array parameter with RemoveArrayKeys', [ |
||
| 36 | 'first-vendor/first-package', |
||
| 37 | 'first-vendor/second-package', |
||
| 38 | 'second-vendor/first-package', |
||
| 39 | 'second-vendor/second-package', |
||
| 40 | 'root value', |
||
| 41 | ]], |
||
| 42 | [ |
||
| 43 | 'callable parameter', |
||
| 44 | new LiterallyCallback(function () { |
||
| 45 | return 'I am callable'; |
||
| 46 | }), |
||
| 47 | ], |
||
| 48 | [ |
||
| 49 | 'static callable parameter', |
||
| 50 | new LiterallyCallback(static function () { |
||
| 51 | return 'I am callable'; |
||
| 52 | }), |
||
| 53 | ], |
||
| 54 | ['object parameter', new stdClass()], |
||
| 55 | /** |
||
| 56 | * Test for subpackages parameters |
||
| 57 | */ |
||
| 58 | ['first-vendor/first-package', true], |
||
| 59 | ['first-vendor/second-package', true], |
||
| 60 | ['first-dev-vendor/first-package', true], |
||
| 61 | ['first-dev-vendor/second-package', true], |
||
| 62 | ['second-vendor/first-package', true], |
||
| 63 | ['second-vendor/second-package', true], |
||
| 64 | ['second-dev-vendor/first-package', true], |
||
| 65 | ['second-dev-vendor/second-package', true], |
||
| 66 | ['constant_based_parameter', 'a constant value defined in config/constants.php'], |
||
| 67 | ['constant_from_vendor', 'a constant value defined in first-dev-vendor/second-package'], |
||
| 68 | ['parameters from .env', [ |
||
| 69 | 'ENV_STRING' => 'string', |
||
| 70 | 'ENV_NUMBER' => '42', |
||
| 71 | 'ENV_TEXT' => 'Some text with several words', |
||
| 72 | ]], |
||
| 73 | ['parameters from .env through constants', [ |
||
| 74 | 'ENV_STRING' => 'string', |
||
| 75 | 'ENV_NUMBER' => '42', |
||
| 76 | 'ENV_TEXT' => 'Some text with several words', |
||
| 77 | ]], |
||
| 78 | ['parameters from YAML', [ |
||
| 79 | 'string value' => 'string', |
||
| 80 | 'boolean value' => true, |
||
| 81 | 'int value' => 42, |
||
| 82 | ]], |
||
| 83 | ['parameters from JSON', [ |
||
| 84 | 'string value' => 'string', |
||
| 85 | 'boolean value' => true, |
||
| 86 | 'int value' => 42, |
||
| 87 | ]], |
||
| 104 |