| Conditions | 1 |
| Paths | 1 |
| Total Lines | 81 |
| Code Lines | 48 |
| 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 |
||
| 114 | public function dataValidationFailed(): array |
||
| 115 | { |
||
| 116 | return [ |
||
| 117 | ['5', [new TrueValue()], ['' => ['The value must be "1".']]], |
||
| 118 | [null, [new TrueValue()], ['' => ['The allowed types are integer, float, string, boolean. null given.']]], |
||
| 119 | [[], [new TrueValue()], ['' => ['The allowed types are integer, float, string, boolean. array given.']]], |
||
| 120 | [true, [new TrueValue(strict: true)], ['' => ['The value must be "1".']]], |
||
| 121 | ['1', [new TrueValue(trueValue: true, strict: true)], ['' => ['The value must be "true".']]], |
||
| 122 | [ |
||
| 123 | [], |
||
| 124 | [new TrueValue(trueValue: true, strict: true)], |
||
| 125 | ['' => ['The allowed types are integer, float, string, boolean. array given.']], |
||
| 126 | ], |
||
| 127 | |||
| 128 | [false, [new TrueValue()], ['' => ['The value must be "1".']]], |
||
| 129 | ['0', [new TrueValue()], ['' => ['The value must be "1".']]], |
||
| 130 | ['0', [new TrueValue(strict: true)], ['' => ['The value must be "1".']]], |
||
| 131 | [false, [new TrueValue(trueValue: true, strict: true)], ['' => ['The value must be "true".']]], |
||
| 132 | |||
| 133 | 'custom message' => [ |
||
| 134 | 5, |
||
| 135 | [new TrueValue(message: 'Custom error.')], |
||
| 136 | ['' => ['Custom error.']], |
||
| 137 | ], |
||
| 138 | 'custom message with parameters' => [ |
||
| 139 | 5, |
||
| 140 | [new TrueValue(message: 'Attribute - {attribute}, true - {true}, value - {value}.')], |
||
| 141 | ['' => ['Attribute - , true - 1, value - 5.']], |
||
| 142 | ], |
||
| 143 | 'custom message with parameters, custom true value, strict' => [ |
||
| 144 | 5, |
||
| 145 | [ |
||
| 146 | new TrueValue( |
||
| 147 | trueValue: true, |
||
| 148 | strict: true, |
||
| 149 | message: 'Attribute - {attribute}, true - {true}, value - {value}.', |
||
| 150 | ), |
||
| 151 | ], |
||
| 152 | ['' => ['Attribute - , true - true, value - 5.']], |
||
| 153 | ], |
||
| 154 | 'custom message with parameters, attribute set' => [ |
||
| 155 | ['data' => 5], |
||
| 156 | [ |
||
| 157 | 'data' => new TrueValue(message: 'Attribute - {attribute}, true - {true}, value - {value}.'), |
||
| 158 | ], |
||
| 159 | ['data' => ['Attribute - data, true - 1, value - 5.']], |
||
| 160 | ], |
||
| 161 | 'custom incorrect input message' => [ |
||
| 162 | [], |
||
| 163 | [new TrueValue(incorrectInputMessage: 'Custom error.')], |
||
| 164 | ['' => ['Custom error.']], |
||
| 165 | ], |
||
| 166 | 'custom incorrect input message with parameters' => [ |
||
| 167 | [], |
||
| 168 | [ |
||
| 169 | new TrueValue(incorrectInputMessage: 'Attribute - {attribute}, true - {true}, type - {type}.'), |
||
| 170 | ], |
||
| 171 | ['' => ['Attribute - , true - 1, type - array.']], |
||
| 172 | ], |
||
| 173 | 'custom incorrect input message with parameters, custom true and false values, strict' => [ |
||
| 174 | [], |
||
| 175 | [ |
||
| 176 | new TrueValue( |
||
| 177 | trueValue: true, |
||
| 178 | strict: true, |
||
| 179 | incorrectInputMessage: 'Attribute - {attribute}, true - {true}, type - {type}.', |
||
| 180 | ), |
||
| 181 | ], |
||
| 182 | ['' => ['Attribute - , true - true, type - array.']], |
||
| 183 | ], |
||
| 184 | 'custom incorrect input message with parameters, attribute set' => [ |
||
| 185 | ['data' => []], |
||
| 186 | [ |
||
| 187 | 'data' => new TrueValue(incorrectInputMessage: 'Attribute - {attribute}, true - {true}, type - {type}.'), |
||
| 188 | ], |
||
| 189 | ['data' => ['Attribute - data, true - 1, type - array.']], |
||
| 190 | ], |
||
| 191 | 'custom incorrect input message, null' => [ |
||
| 192 | null, |
||
| 193 | [new TrueValue(incorrectInputMessage: 'Attribute - {attribute}, true - {true}, type - {type}.'),], |
||
| 194 | ['' => ['Attribute - , true - 1, type - null.']], |
||
| 195 | ], |
||
| 215 |