| Conditions | 2 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 3 | public function getRules(): array |
|
| 36 | { |
||
| 37 | return [ |
||
| 38 | 'body.title' => [ |
||
| 39 | 3 | new Required(), |
|
| 40 | 3 | (new HasLength()) |
|
| 41 | 3 | ->min(5) |
|
| 42 | 3 | ->max(255), |
|
| 43 | ], |
||
| 44 | 'body.text' => [ |
||
| 45 | 3 | new Required(), |
|
| 46 | 3 | (new HasLength()) |
|
| 47 | 3 | ->min(5) |
|
| 48 | 3 | ->max(1000), |
|
| 49 | ], |
||
| 50 | 'body.status' => [ |
||
| 51 | 3 | new Required(), |
|
| 52 | 3 | static function ($value): Result { |
|
| 53 | 3 | $result = new Result(); |
|
| 54 | 3 | if (!PostStatus::isValid($value)) { |
|
| 55 | 1 | $result->addError('Incorrect status'); |
|
| 56 | } |
||
| 57 | 3 | return $result; |
|
| 58 | 3 | }, |
|
| 63 |