AssetMeta::getUpdatedAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Seams-CMS Delivery SDK 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 7
    final protected function __construct()
41
    {
42 7
    }
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 1
    public function getCreatedBy(): string
56
    {
57 1
        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 1
    public function getUpdatedBy(): string
72
    {
73 1
        return $this->updatedBy;
74
    }
75
76
    /**
77
     * @param array $data
78
     * @return AssetMeta
79
     * @throws \Exception
80
     */
81 7
    public static function fromArray(array $data)
82
    {
83 7
        if (isset($data['created_at'])) {
84 1
            $data['created_at'] = new \DateTimeImmutable($data['created_at']);
85
        }
86 7
        if (isset($data['updated_at'])) {
87 1
            $data['updated_at'] = new \DateTimeImmutable($data['updated_at']);
88
        }
89
90 7
        return self::fromArrayTrait($data);
91
    }
92
}
93