Completed
Push — master ( cd00c2...c10be1 )
by Joshua
13s queued 11s
created

AssetMeta::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
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
    /**
37
     * AssetMeta constructor.
38
     *
39
     */
40 5
    protected function __construct()
41
    {
42 5
    }
43
44
    /**
45
     * @return \DateTimeImmutable
46
     */
47 1
    public function getCreatedAt(): \DateTimeImmutable
48
    {
49 1
        return $this->createdAt;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getCreatedBy(): string
56
    {
57
        return $this->createdBy;
58
    }
59
60
    /**
61
     * @return \DateTimeImmutable
62
     */
63 1
    public function getUpdatedAt(): \DateTimeImmutable
64
    {
65 1
        return $this->updatedAt;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getUpdatedBy(): string
72
    {
73
        return $this->updatedBy;
74
    }
75
76
    /**
77
     * @param array $data
78
     * @return AssetMeta
79
     * @throws \Exception
80
     */
81 5
    public static function fromArray(array $data)
82
    {
83 5
        if (isset($data['created_at'])) {
84 1
            $data['created_at'] = new \DateTimeImmutable($data['created_at']);
85
        }
86 5
        if (isset($data['updated_at'])) {
87 1
            $data['updated_at'] = new \DateTimeImmutable($data['updated_at']);
88
        }
89
90 5
        return self::fromArrayTrait($data);
91
    }
92
}
93