| Conditions | 1 |
| Paths | 1 |
| Total Lines | 65 |
| Code Lines | 44 |
| 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 |
||
| 83 | public function createValidatorFailureProvider(): array |
||
| 84 | { |
||
| 85 | return [ |
||
| 86 | 'invalid-data-missing-name' => [ |
||
| 87 | [ |
||
| 88 | 'to_name' => 'bar', |
||
| 89 | 'to_email' => '[email protected]', |
||
| 90 | 'success_url' => 'https://example.com/success', |
||
| 91 | 'failure_url' => 'https://failure.example.com/', |
||
| 92 | 'max_body_length' => '255', |
||
| 93 | ], |
||
| 94 | ], |
||
| 95 | 'invalid-data-missing-to_name' => [ |
||
| 96 | [ |
||
| 97 | 'name' => 'foo', |
||
| 98 | 'to_email' => '[email protected]', |
||
| 99 | 'success_url' => 'https://example.com/success', |
||
| 100 | 'failure_url' => 'https://failure.example.com/', |
||
| 101 | 'max_body_length' => '255', |
||
| 102 | ], |
||
| 103 | ], |
||
| 104 | 'invalid-data-missing-to_email' => [ |
||
| 105 | [ |
||
| 106 | 'name' => 'foo', |
||
| 107 | 'to_name' => 'bar', |
||
| 108 | 'success_url' => 'https://example.com/success', |
||
| 109 | 'failure_url' => 'https://failure.example.com/', |
||
| 110 | 'max_body_length' => '255', |
||
| 111 | ], |
||
| 112 | ], |
||
| 113 | 'invalid-data-missing-success_url' => [ |
||
| 114 | [ |
||
| 115 | 'name' => 'foo', |
||
| 116 | 'to_name' => 'bar', |
||
| 117 | 'to_email' => '[email protected]', |
||
| 118 | 'failure_url' => 'https://failure.example.com/', |
||
| 119 | 'max_body_length' => '255', |
||
| 120 | ], |
||
| 121 | ], |
||
| 122 | 'invalid-data-missing-failure_url' => [ |
||
| 123 | [ |
||
| 124 | 'name' => 'foo', |
||
| 125 | 'to_name' => 'bar', |
||
| 126 | 'to_email' => '[email protected]', |
||
| 127 | 'success_url' => 'https://example.com/success', |
||
| 128 | 'max_body_length' => '255', |
||
| 129 | ], |
||
| 130 | ], |
||
| 131 | 'invalid-data-missing-max_body_length' => [ |
||
| 132 | [ |
||
| 133 | 'name' => 'foo', |
||
| 134 | 'to_name' => 'bar', |
||
| 135 | 'to_email' => '[email protected]', |
||
| 136 | 'success_url' => 'https://example.com/success', |
||
| 137 | 'failure_url' => 'https://failure.example.com/', |
||
| 138 | ], |
||
| 139 | ], |
||
| 140 | 'invalid-data-non-numeric-body_length' => [ |
||
| 141 | [ |
||
| 142 | 'name' => 'foo', |
||
| 143 | 'to_name' => 'bar', |
||
| 144 | 'to_email' => '[email protected]', |
||
| 145 | 'success_url' => 'https://example.com/success', |
||
| 146 | 'failure_url' => 'https://failure.example.com/', |
||
| 147 | 'max_body_length' => 'abc', |
||
| 148 | ], |
||
| 178 |