| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 | public function dataValidationPassed(): array |
||
| 26 | { |
||
| 27 | return [ |
||
| 28 | ['2024-08-15T15:52:01+00:00', [new DateTime(formats: DateTimeInterface::W3C)]], |
||
| 29 | ['2024-08-15 15:52:01', [new DateTime(formats: 'Y-m-d H:i:s')]], |
||
| 30 | ['15-08-2024 15:52', [new DateTime(formats: 'd-m-Y H:i')]], |
||
| 31 | [ |
||
| 32 | '2024-08-15 15:52:01', |
||
| 33 | [ |
||
| 34 | new DateTime( |
||
| 35 | min: null, |
||
| 36 | max: null, |
||
| 37 | message: 'The value must be between 2024-08-15 15:52:01 and 2024-08-15 15:52:01.', |
||
| 38 | lessThanMinMessage: 'The value must be no less than 2024-08-15 15:52:01.', |
||
| 39 | greaterThanMaxMessage: 'The value must be no greater than 2024-08-15 15:52:01.', |
||
| 40 | skipOnEmpty: false, |
||
| 41 | skipOnError: false, |
||
| 42 | when: null, |
||
| 43 | formats: 'Y-m-d H:i:s', format: DateTimeInterface::W3C, |
||
| 44 | ), |
||
| 45 | ], |
||
| 46 | ], |
||
| 47 | [ |
||
| 48 | '2024-08-15 15:52:01', |
||
| 49 | [ |
||
| 50 | new DateTime( |
||
| 51 | min: new DateTimeImmutable('2024-08-15 15:52:01'), |
||
| 52 | formats: 'Y-m-d H:i:s' |
||
| 53 | ), |
||
| 54 | ], |
||
| 55 | ], |
||
| 56 | [ |
||
| 57 | new DateTimeImmutable('2024-08-15 15:52:01'), |
||
| 58 | [new DateTime(formats: 'Y-m-d H:i:s')], |
||
| 59 | ], |
||
| 60 | [ |
||
| 61 | '2024-08-15 15:51:59', |
||
| 62 | [ |
||
| 63 | new DateTime( |
||
| 64 | max: new DateTimeImmutable('2024-08-15 15:52:01'), |
||
| 65 | formats: 'Y-m-d H:i:s' |
||
| 66 | ), |
||
| 67 | ], |
||
| 68 | ], |
||
| 69 | [ |
||
| 70 | '2024-08-15 15:52:01', |
||
| 71 | [ |
||
| 72 | new DateTime( |
||
| 73 | max: new DateTimeImmutable('2024-08-15 15:52:01'), |
||
| 74 | formats: 'Y-m-d H:i:s' |
||
| 75 | ), |
||
| 76 | ], |
||
| 77 | ['' => [' must be no greater than 2024-08-15 15:52:01.']], |
||
| 78 | ], |
||
| 79 | |||
| 80 | [ |
||
| 81 | 1705322898, |
||
| 82 | [new DateTime()], |
||
| 83 | ['' => [' value is not a valid DateTime.']], |
||
| 84 | ], |
||
| 176 |