Completed
Push — master ( 7b2ae7...b60607 )
by Dominik
06:56
created

CourseMapping::getClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiSkeleton\Deserialization;
6
7
use Chubbyphp\ApiSkeleton\Model\Document;
8
use Chubbyphp\Deserialization\Mapping\ObjectMappingInterface;
9
use Chubbyphp\Deserialization\Mapping\PropertyMapping;
10
use Chubbyphp\Deserialization\Mapping\PropertyMappingInterface;
11
use Chubbyphp\ApiSkeleton\Model\Course;
12
use Chubbyphp\DeserializationModel\Deserializer\PropertyModelCollectionDeserializer;
13
14
final class CourseMapping implements ObjectMappingInterface
15
{
16
    /**
17
     * @return string
18
     */
19 1
    public function getClass(): string
20
    {
21 1
        return Course::class;
22
    }
23
24
    /**
25
     * @return callable
26
     */
27 1
    public function getFactory(): callable
28
    {
29 1
        return [Course::class, 'create'];
30
    }
31
32
    /**
33
     * @return PropertyMappingInterface[]
34
     */
35 1
    public function getPropertyMappings(): array
36
    {
37
        return [
38 1
            new PropertyMapping('name'),
39 1
            new PropertyMapping('level'),
40 1
            new PropertyMapping('progress'),
41 1
            new PropertyMapping('active'),
42 1
            new PropertyMapping('documents', new PropertyModelCollectionDeserializer(Document::class, true)),
43
        ];
44
    }
45
}
46