| Conditions | 1 |
| Paths | 1 |
| Total Lines | 357 |
| Code Lines | 256 |
| 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 |
||
| 56 | public function dataOptions(): array |
||
| 57 | { |
||
| 58 | return [ |
||
| 59 | [ |
||
| 60 | new Compare(1), |
||
| 61 | [ |
||
| 62 | 'targetValue' => 1, |
||
| 63 | 'targetAttribute' => null, |
||
| 64 | 'incorrectInputMessage' => [ |
||
| 65 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 66 | 'parameters' => [ |
||
| 67 | 'targetValue' => 1, |
||
| 68 | 'targetAttribute' => null, |
||
| 69 | 'targetValueOrAttribute' => 1, |
||
| 70 | ], |
||
| 71 | ], |
||
| 72 | 'incorrectDataSetTypeMessage' => [ |
||
| 73 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 74 | 'parameters' => [ |
||
| 75 | 'targetValue' => 1, |
||
| 76 | 'targetAttribute' => null, |
||
| 77 | 'targetValueOrAttribute' => 1, |
||
| 78 | ], |
||
| 79 | ], |
||
| 80 | 'message' => [ |
||
| 81 | 'template' => 'Value must be equal to "{targetValueOrAttribute}".', |
||
| 82 | 'parameters' => [ |
||
| 83 | 'targetValue' => 1, |
||
| 84 | 'targetAttribute' => null, |
||
| 85 | 'targetValueOrAttribute' => 1, |
||
| 86 | ], |
||
| 87 | ], |
||
| 88 | 'type' => 'string', |
||
| 89 | 'operator' => '==', |
||
| 90 | 'skipOnEmpty' => false, |
||
| 91 | 'skipOnError' => false, |
||
| 92 | ], |
||
| 93 | ], |
||
| 94 | [ |
||
| 95 | new Compare(1, type: CompareType::NUMBER), |
||
| 96 | [ |
||
| 97 | 'targetValue' => 1, |
||
| 98 | 'targetAttribute' => null, |
||
| 99 | 'incorrectInputMessage' => [ |
||
| 100 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 101 | 'parameters' => [ |
||
| 102 | 'targetValue' => 1, |
||
| 103 | 'targetAttribute' => null, |
||
| 104 | 'targetValueOrAttribute' => 1, |
||
| 105 | ], |
||
| 106 | ], |
||
| 107 | 'incorrectDataSetTypeMessage' => [ |
||
| 108 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 109 | 'parameters' => [ |
||
| 110 | 'targetValue' => 1, |
||
| 111 | 'targetAttribute' => null, |
||
| 112 | 'targetValueOrAttribute' => 1, |
||
| 113 | ], |
||
| 114 | ], |
||
| 115 | 'message' => [ |
||
| 116 | 'template' => 'Value must be equal to "{targetValueOrAttribute}".', |
||
| 117 | 'parameters' => [ |
||
| 118 | 'targetValue' => 1, |
||
| 119 | 'targetAttribute' => null, |
||
| 120 | 'targetValueOrAttribute' => 1, |
||
| 121 | ], |
||
| 122 | ], |
||
| 123 | 'type' => 'number', |
||
| 124 | 'operator' => '==', |
||
| 125 | 'skipOnEmpty' => false, |
||
| 126 | 'skipOnError' => false, |
||
| 127 | ], |
||
| 128 | ], |
||
| 129 | [ |
||
| 130 | new Compare(1, type: CompareType::NUMBER, operator: '>='), |
||
| 131 | [ |
||
| 132 | 'targetValue' => 1, |
||
| 133 | 'targetAttribute' => null, |
||
| 134 | 'incorrectInputMessage' => [ |
||
| 135 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 136 | 'parameters' => [ |
||
| 137 | 'targetValue' => 1, |
||
| 138 | 'targetAttribute' => null, |
||
| 139 | 'targetValueOrAttribute' => 1, |
||
| 140 | ], |
||
| 141 | ], |
||
| 142 | 'incorrectDataSetTypeMessage' => [ |
||
| 143 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 144 | 'parameters' => [ |
||
| 145 | 'targetValue' => 1, |
||
| 146 | 'targetAttribute' => null, |
||
| 147 | 'targetValueOrAttribute' => 1, |
||
| 148 | ], |
||
| 149 | ], |
||
| 150 | 'message' => [ |
||
| 151 | 'template' => 'Value must be greater than or equal to "{targetValueOrAttribute}".', |
||
| 152 | 'parameters' => [ |
||
| 153 | 'targetValue' => 1, |
||
| 154 | 'targetAttribute' => null, |
||
| 155 | 'targetValueOrAttribute' => 1, |
||
| 156 | ], |
||
| 157 | ], |
||
| 158 | 'type' => 'number', |
||
| 159 | 'operator' => '>=', |
||
| 160 | 'skipOnEmpty' => false, |
||
| 161 | 'skipOnError' => false, |
||
| 162 | ], |
||
| 163 | ], |
||
| 164 | [ |
||
| 165 | new Compare('YES'), |
||
| 166 | [ |
||
| 167 | 'targetValue' => 'YES', |
||
| 168 | 'targetAttribute' => null, |
||
| 169 | 'incorrectInputMessage' => [ |
||
| 170 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 171 | 'parameters' => [ |
||
| 172 | 'targetValue' => 'YES', |
||
| 173 | 'targetAttribute' => null, |
||
| 174 | 'targetValueOrAttribute' => 'YES', |
||
| 175 | ], |
||
| 176 | ], |
||
| 177 | 'incorrectDataSetTypeMessage' => [ |
||
| 178 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 179 | 'parameters' => [ |
||
| 180 | 'targetValue' => 'YES', |
||
| 181 | 'targetAttribute' => null, |
||
| 182 | 'targetValueOrAttribute' => 'YES', |
||
| 183 | ], |
||
| 184 | ], |
||
| 185 | 'message' => [ |
||
| 186 | 'template' => 'Value must be equal to "{targetValueOrAttribute}".', |
||
| 187 | 'parameters' => [ |
||
| 188 | 'targetValue' => 'YES', |
||
| 189 | 'targetAttribute' => null, |
||
| 190 | 'targetValueOrAttribute' => 'YES', |
||
| 191 | ], |
||
| 192 | ], |
||
| 193 | 'type' => 'string', |
||
| 194 | 'operator' => '==', |
||
| 195 | 'skipOnEmpty' => false, |
||
| 196 | 'skipOnError' => false, |
||
| 197 | ], |
||
| 198 | ], |
||
| 199 | [ |
||
| 200 | new Compare('YES', skipOnEmpty: true), |
||
| 201 | [ |
||
| 202 | 'targetValue' => 'YES', |
||
| 203 | 'targetAttribute' => null, |
||
| 204 | 'incorrectInputMessage' => [ |
||
| 205 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 206 | 'parameters' => [ |
||
| 207 | 'targetValue' => 'YES', |
||
| 208 | 'targetAttribute' => null, |
||
| 209 | 'targetValueOrAttribute' => 'YES', |
||
| 210 | ], |
||
| 211 | ], |
||
| 212 | 'incorrectDataSetTypeMessage' => [ |
||
| 213 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 214 | 'parameters' => [ |
||
| 215 | 'targetValue' => 'YES', |
||
| 216 | 'targetAttribute' => null, |
||
| 217 | 'targetValueOrAttribute' => 'YES', |
||
| 218 | ], |
||
| 219 | ], |
||
| 220 | 'message' => [ |
||
| 221 | 'template' => 'Value must be equal to "{targetValueOrAttribute}".', |
||
| 222 | 'parameters' => [ |
||
| 223 | 'targetValue' => 'YES', |
||
| 224 | 'targetAttribute' => null, |
||
| 225 | 'targetValueOrAttribute' => 'YES', |
||
| 226 | ], |
||
| 227 | ], |
||
| 228 | 'type' => 'string', |
||
| 229 | 'operator' => '==', |
||
| 230 | 'skipOnEmpty' => true, |
||
| 231 | 'skipOnError' => false, |
||
| 232 | ], |
||
| 233 | ], |
||
| 234 | [ |
||
| 235 | new Compare('YES', operator: '!=='), |
||
| 236 | [ |
||
| 237 | 'targetValue' => 'YES', |
||
| 238 | 'targetAttribute' => null, |
||
| 239 | 'incorrectInputMessage' => [ |
||
| 240 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 241 | 'parameters' => [ |
||
| 242 | 'targetValue' => 'YES', |
||
| 243 | 'targetAttribute' => null, |
||
| 244 | 'targetValueOrAttribute' => 'YES', |
||
| 245 | ], |
||
| 246 | ], |
||
| 247 | 'incorrectDataSetTypeMessage' => [ |
||
| 248 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 249 | 'parameters' => [ |
||
| 250 | 'targetValue' => 'YES', |
||
| 251 | 'targetAttribute' => null, |
||
| 252 | 'targetValueOrAttribute' => 'YES', |
||
| 253 | ], |
||
| 254 | ], |
||
| 255 | 'message' => [ |
||
| 256 | 'template' => 'Value must not be equal to "{targetValueOrAttribute}".', |
||
| 257 | 'parameters' => [ |
||
| 258 | 'targetValue' => 'YES', |
||
| 259 | 'targetAttribute' => null, |
||
| 260 | 'targetValueOrAttribute' => 'YES', |
||
| 261 | ], |
||
| 262 | ], |
||
| 263 | 'type' => 'string', |
||
| 264 | 'operator' => '!==', |
||
| 265 | 'skipOnEmpty' => false, |
||
| 266 | 'skipOnError' => false, |
||
| 267 | ], |
||
| 268 | ], |
||
| 269 | [ |
||
| 270 | new Compare('YES', message: 'Custom message for {targetValueOrAttribute}.'), |
||
| 271 | [ |
||
| 272 | 'targetValue' => 'YES', |
||
| 273 | 'targetAttribute' => null, |
||
| 274 | 'incorrectInputMessage' => [ |
||
| 275 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 276 | 'parameters' => [ |
||
| 277 | 'targetValue' => 'YES', |
||
| 278 | 'targetAttribute' => null, |
||
| 279 | 'targetValueOrAttribute' => 'YES', |
||
| 280 | ], |
||
| 281 | ], |
||
| 282 | 'incorrectDataSetTypeMessage' => [ |
||
| 283 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 284 | 'parameters' => [ |
||
| 285 | 'targetValue' => 'YES', |
||
| 286 | 'targetAttribute' => null, |
||
| 287 | 'targetValueOrAttribute' => 'YES', |
||
| 288 | ], |
||
| 289 | ], |
||
| 290 | 'message' => [ |
||
| 291 | 'template' => 'Custom message for {targetValueOrAttribute}.', |
||
| 292 | 'parameters' => [ |
||
| 293 | 'targetValue' => 'YES', |
||
| 294 | 'targetAttribute' => null, |
||
| 295 | 'targetValueOrAttribute' => 'YES', |
||
| 296 | ], |
||
| 297 | ], |
||
| 298 | 'type' => 'string', |
||
| 299 | 'operator' => '==', |
||
| 300 | 'skipOnEmpty' => false, |
||
| 301 | 'skipOnError' => false, |
||
| 302 | ], |
||
| 303 | ], |
||
| 304 | [ |
||
| 305 | new Compare(null, 'test'), |
||
| 306 | [ |
||
| 307 | 'targetValue' => null, |
||
| 308 | 'targetAttribute' => 'test', |
||
| 309 | 'incorrectInputMessage' => [ |
||
| 310 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 311 | 'parameters' => [ |
||
| 312 | 'targetValue' => null, |
||
| 313 | 'targetAttribute' => 'test', |
||
| 314 | 'targetValueOrAttribute' => 'test', |
||
| 315 | ], |
||
| 316 | ], |
||
| 317 | 'incorrectDataSetTypeMessage' => [ |
||
| 318 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 319 | 'parameters' => [ |
||
| 320 | 'targetValue' => null, |
||
| 321 | 'targetAttribute' => 'test', |
||
| 322 | 'targetValueOrAttribute' => 'test', |
||
| 323 | ], |
||
| 324 | ], |
||
| 325 | 'message' => [ |
||
| 326 | 'template' => 'Value must be equal to "{targetValueOrAttribute}".', |
||
| 327 | 'parameters' => [ |
||
| 328 | 'targetValue' => null, |
||
| 329 | 'targetAttribute' => 'test', |
||
| 330 | 'targetValueOrAttribute' => 'test', |
||
| 331 | ], |
||
| 332 | ], |
||
| 333 | 'type' => 'string', |
||
| 334 | 'operator' => '==', |
||
| 335 | 'skipOnEmpty' => false, |
||
| 336 | 'skipOnError' => false, |
||
| 337 | ], |
||
| 338 | ], |
||
| 339 | [ |
||
| 340 | new Compare( |
||
| 341 | null, |
||
| 342 | 'test', |
||
| 343 | incorrectInputMessage: 'Custom message 1.', |
||
| 344 | incorrectDataSetTypeMessage: 'Custom message 2.', |
||
| 345 | message: 'Custom message 3.', |
||
| 346 | ), |
||
| 347 | [ |
||
| 348 | 'targetValue' => null, |
||
| 349 | 'targetAttribute' => 'test', |
||
| 350 | 'incorrectInputMessage' => [ |
||
| 351 | 'template' => 'Custom message 1.', |
||
| 352 | 'parameters' => [ |
||
| 353 | 'targetValue' => null, |
||
| 354 | 'targetAttribute' => 'test', |
||
| 355 | 'targetValueOrAttribute' => 'test', |
||
| 356 | ], |
||
| 357 | ], |
||
| 358 | 'incorrectDataSetTypeMessage' => [ |
||
| 359 | 'template' => 'Custom message 2.', |
||
| 360 | 'parameters' => [ |
||
| 361 | 'targetValue' => null, |
||
| 362 | 'targetAttribute' => 'test', |
||
| 363 | 'targetValueOrAttribute' => 'test', |
||
| 364 | ], |
||
| 365 | ], |
||
| 366 | 'message' => [ |
||
| 367 | 'template' => 'Custom message 3.', |
||
| 368 | 'parameters' => [ |
||
| 369 | 'targetValue' => null, |
||
| 370 | 'targetAttribute' => 'test', |
||
| 371 | 'targetValueOrAttribute' => 'test', |
||
| 372 | ], |
||
| 373 | ], |
||
| 374 | 'type' => 'string', |
||
| 375 | 'operator' => '==', |
||
| 376 | 'skipOnEmpty' => false, |
||
| 377 | 'skipOnError' => false, |
||
| 378 | ], |
||
| 379 | ], |
||
| 380 | [ |
||
| 381 | new Compare(1, 'test'), |
||
| 382 | [ |
||
| 383 | 'targetValue' => 1, |
||
| 384 | 'targetAttribute' => 'test', |
||
| 385 | 'incorrectInputMessage' => [ |
||
| 386 | 'template' => 'The allowed types are integer, float, string, boolean and null.', |
||
| 387 | 'parameters' => [ |
||
| 388 | 'targetValue' => 1, |
||
| 389 | 'targetAttribute' => 'test', |
||
| 390 | 'targetValueOrAttribute' => 1, |
||
| 391 | ], |
||
| 392 | ], |
||
| 393 | 'incorrectDataSetTypeMessage' => [ |
||
| 394 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', |
||
| 395 | 'parameters' => [ |
||
| 396 | 'targetValue' => 1, |
||
| 397 | 'targetAttribute' => 'test', |
||
| 398 | 'targetValueOrAttribute' => 1, |
||
| 399 | ], |
||
| 400 | ], |
||
| 401 | 'message' => [ |
||
| 402 | 'template' => 'Value must be equal to "{targetValueOrAttribute}".', |
||
| 403 | 'parameters' => [ |
||
| 404 | 'targetValue' => 1, |
||
| 405 | 'targetAttribute' => 'test', |
||
| 406 | 'targetValueOrAttribute' => 1, |
||
| 407 | ], |
||
| 408 | ], |
||
| 409 | 'type' => 'string', |
||
| 410 | 'operator' => '==', |
||
| 411 | 'skipOnEmpty' => false, |
||
| 412 | 'skipOnError' => false, |
||
| 413 | ], |
||
| 615 |