Passed
Push — master ( 443842...86f0b2 )
by Joshua
05:55 queued 01:59
created

ContentType::fromArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SeamsCMS\Delivery\Model;
6
7
class ContentType
8
{
9
    use HydratorTrait {
10
        fromArray as private fromArrayTrait;
11
    }
12
13
    /** @var string */
14
    private $id;
15
    /** @var string */
16
    private $name;
17
    /** @var string */
18
    private $description;
19
    /** @var ContentTypeField[] */
20
    private $fields;
21
22
    /**
23
     * @return string
24
     */
25
    public function getId(): string
26
    {
27
        return $this->id;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getName(): string
34
    {
35
        return $this->name;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getDescription(): string
42
    {
43
        return $this->description;
44
    }
45
46
    /**
47
     * @return ContentTypeField[]
48
     */
49
    public function getFields(): array
50
    {
51
        return $this->fields;
52
    }
53
54
    public static function fromArray(array $data)
55
    {
56
        $data['fields'] = array_map(function ($item) {
57
            return ContentTypeField::fromArray($item);
58
        }, $data['fields']);
59
60
        return self::fromArrayTrait($data);
61
    }
62
}
63