Test Failed
Pull Request — master (#87)
by Dmitriy
03:15
created

Request::getRules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\IO\Http\Auth\PostLogin\Request;
6
7
use OpenApi\Annotations as OA;
8
use Yiisoft\RequestModel\RequestModel;
9
use Yiisoft\Validator\Rule\Required;
10
use Yiisoft\Validator\RulesProviderInterface;
11
12
/**
13
 * @OA\Schema(
14
 *      schema="LoginRequest",
15
 *      @OA\Property(example="Opal1144", property="login", format="string"),
16
 *      @OA\Property(example="Opal1144", property="password", format="string"),
17
 * )
18
 */
19
final class Request extends RequestModel implements RulesProviderInterface
20
{
21
    public function getLogin(): string
22
    {
23
        return (string)$this->getAttributeValue('body.login');
24
    }
25
26
    public function getPassword(): string
27
    {
28
        return (string)$this->getAttributeValue('body.password');
29
    }
30
31
    public function getRules(): array
32
    {
33
        return [
34
            'body.login' => [
35
                new Required(),
36
            ],
37
            'body.password' => [
38
                new Required(),
39
            ],
40
        ];
41
    }
42
}
43