|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Infrastructure\IO\Http\Blog\PutUpdate\Request; |
|
6
|
|
|
|
|
7
|
|
|
use App\Application\Blog\Entity\Post\PostStatus; |
|
8
|
|
|
use OpenApi\Annotations as OA; |
|
|
|
|
|
|
9
|
|
|
use Yiisoft\Hydrator\Validator\Attribute\Validate; |
|
|
|
|
|
|
10
|
|
|
use Yiisoft\Input\Http\AbstractInput; |
|
|
|
|
|
|
11
|
|
|
use Yiisoft\Input\Http\Attribute\Parameter\Body; |
|
|
|
|
|
|
12
|
|
|
use Yiisoft\Hydrator\Temp\RouteArgument; |
|
|
|
|
|
|
13
|
|
|
use Yiisoft\Validator\Result; |
|
|
|
|
|
|
14
|
|
|
use Yiisoft\Validator\Rule\Length; |
|
|
|
|
|
|
15
|
|
|
use Yiisoft\Validator\Rule\Required; |
|
|
|
|
|
|
16
|
|
|
use Yiisoft\Validator\RulesProviderInterface; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @OA\Schema( |
|
20
|
|
|
* schema="BlogUpdateRequest", |
|
21
|
|
|
* @OA\Property(example="Title post", property="title", format="string"), |
|
22
|
|
|
* @OA\Property(example="Text post", property="text", format="string"), |
|
23
|
|
|
* @OA\Property(example=1, property="status", format="int"), |
|
24
|
|
|
* ) |
|
25
|
|
|
*/ |
|
26
|
|
|
final class Request extends AbstractInput implements RulesProviderInterface |
|
27
|
|
|
{ |
|
28
|
|
|
#[RouteArgument('id')] |
|
29
|
|
|
private int $id; |
|
30
|
|
|
|
|
31
|
|
|
#[Body('title')] |
|
32
|
|
|
#[Validate(new Required())] |
|
33
|
|
|
private string $title = ''; |
|
34
|
|
|
|
|
35
|
|
|
#[Body('text')] |
|
36
|
|
|
#[Validate(new Required())] |
|
37
|
|
|
private string $text = ''; |
|
38
|
|
|
|
|
39
|
|
|
#[Body('status')] |
|
40
|
|
|
#[Validate(new Required())] |
|
41
|
|
|
private int $status; |
|
42
|
|
|
|
|
43
|
|
|
public function getId(): int |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->id; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getTitle(): string |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->title; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function getText(): string |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->text; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getStatus(): PostStatus |
|
59
|
|
|
{ |
|
60
|
|
|
return PostStatus::from($this->status); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function getRules(): array |
|
64
|
|
|
{ |
|
65
|
|
|
return [ |
|
66
|
|
|
'title' => [ |
|
67
|
|
|
new Length(min: 5, max: 255), |
|
68
|
|
|
], |
|
69
|
|
|
'text' => [ |
|
70
|
|
|
new Length(min: 5, max: 1000), |
|
71
|
|
|
], |
|
72
|
|
|
'status' => [ |
|
73
|
|
|
static function ($value): Result { |
|
74
|
|
|
$result = new Result(); |
|
75
|
|
|
if (!PostStatus::isValid($value)) { |
|
76
|
|
|
$result->addError('Incorrect status'); |
|
77
|
|
|
} |
|
78
|
|
|
return $result; |
|
79
|
|
|
}, |
|
80
|
|
|
], |
|
81
|
|
|
]; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths