CourseSearchMapping::getPropertyMappings()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
ccs 14
cts 14
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiSkeleton\Validation;
6
7
use Chubbyphp\ApiSkeleton\Search\CourseSearch;
8
use Chubbyphp\Validation\Constraint\ChoiceConstraint;
9
use Chubbyphp\Validation\Constraint\ConstraintInterface;
10
use Chubbyphp\Validation\Constraint\NotNullConstraint;
11
use Chubbyphp\Validation\Constraint\NumericConstraint;
12
use Chubbyphp\Validation\Constraint\NumericRangeConstraint;
13
use Chubbyphp\Validation\Mapping\PropertyMapping;
14
use Chubbyphp\Validation\Mapping\PropertyMappingInterface;
15
use Chubbyphp\Validation\Mapping\ObjectMappingInterface;
16
17
final class CourseSearchMapping implements ObjectMappingInterface
18
{
19
    /**
20
     * @return string
21
     */
22 1
    public function getClass(): string
23
    {
24 1
        return CourseSearch::class;
25
    }
26
27
    /**
28
     * @return ConstraintInterface[]
29
     */
30 1
    public function getConstraints(): array
31
    {
32 1
        return [];
33
    }
34
35
    /**
36
     * @return PropertyMappingInterface[]
37
     */
38 1
    public function getPropertyMappings(): array
39
    {
40
        return [
41 1
            new PropertyMapping('page', [
42 1
                new NotNullConstraint(),
43 1
                new NumericConstraint(),
44 1
                new NumericRangeConstraint(1),
45
            ]),
46 1
            new PropertyMapping('perPage', [
47 1
                new NotNullConstraint(),
48 1
                new NumericConstraint(),
49 1
                new NumericRangeConstraint(1),
50
            ]),
51 1
            new PropertyMapping('sort', [
52 1
                new ChoiceConstraint(ChoiceConstraint::TYPE_STRING, CourseSearch::SORT),
53
            ]),
54 1
            new PropertyMapping('order', [
55 1
                new NotNullConstraint(),
56 1
                new ChoiceConstraint(ChoiceConstraint::TYPE_STRING, CourseSearch::ORDER),
57
            ]),
58
        ];
59
    }
60
}
61