Passed
Pull Request — master (#61)
by Daniel
06:02
created

TimestampedTrait::setModifiedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentsBundle\Entity\Utility;
15
16
use DateTime;
17
use DateTimeImmutable;
18
19
/**
20
 * @author Daniel West <[email protected]>
21
 */
22
trait TimestampedTrait
23
{
24
    private ?DateTimeImmutable $createdAt = null;
25
26
    public ?DateTime $modifiedAt = null;
27
28
    /** @return static */
29 7
    public function setCreatedAt(DateTimeImmutable $createdAt)
30
    {
31 7
        if (!$this->createdAt) {
32 7
            $this->createdAt = $createdAt;
33
        }
34
35 7
        return $this;
36
    }
37
38
    public function getCreatedAt(): ?DateTimeImmutable
39
    {
40
        return $this->createdAt;
41
    }
42
43
    /** @return static */
44 7
    public function setModifiedAt(DateTime $modifiedAt)
45
    {
46 7
        $this->modifiedAt = $modifiedAt;
47
48 7
        return $this;
49
    }
50
51
    public function getModifiedAt(): ?DateTime
52
    {
53
        return $this->modifiedAt;
54
    }
55
}
56