Passed
Push — master ( 5649e5...cd00c2 )
by Joshua
05:29 queued 03:33
created

AssetMeta::fromArray()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 4
nop 1
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the -SeamsCMSDeliverySdk package.
7
 *
8
 * (c) Seams-CMS.com
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace SeamsCMS\Delivery\Model;
15
16
/**
17
 * Class AssetMeta
18
 * @package SeamsCMS\Delivery\Model
19
 */
20
class AssetMeta
21
{
22
    use HydratorTrait {
23
        fromArray as private fromArrayTrait;
24
    }
25
26
    /** @var \DateTimeImmutable */
27
    private $createdAt;
28
    /** @var string */
29
    private $createdBy;
30
    /** @var \DateTimeImmutable */
31
    private $updatedAt;
32
    /** @var string */
33
    private $updatedBy;
34
35
    /**
36
     * @return \DateTimeImmutable
37
     */
38 1
    public function getCreatedAt(): \DateTimeImmutable
39
    {
40 1
        return $this->createdAt;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getCreatedBy(): string
47
    {
48
        return $this->createdBy;
49
    }
50
51
    /**
52
     * @return \DateTimeImmutable
53
     */
54 1
    public function getUpdatedAt(): \DateTimeImmutable
55
    {
56 1
        return $this->updatedAt;
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getUpdatedBy(): string
63
    {
64
        return $this->updatedBy;
65
    }
66
67
    /**
68
     * @param array $data
69
     * @return AssetMeta
70
     * @throws \Exception
71
     */
72 5
    public static function fromArray(array $data)
73
    {
74 5
        if (isset($data['created_at'])) {
75 1
            $data['created_at'] = new \DateTimeImmutable($data['created_at']);
76
        }
77 5
        if (isset($data['updated_at'])) {
78 1
            $data['updated_at'] = new \DateTimeImmutable($data['updated_at']);
79
        }
80
81 5
        return self::fromArrayTrait($data);
82
    }
83
}
84