Passed
Pull Request — master (#4)
by Alex
09:00
created

DateCreatedAwareTrait::getDateCreated()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 1
c 1
b 1
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\DateTime\Entity;
6
7
/**
8
 * @author  Alex Patterson <[email protected]>
9
 * @package Arp\DateTime\Entity
10
 */
11
trait DateCreatedAwareTrait
12
{
13
    /**
14
     * @var \DateTimeInterface|null
15
     */
16
    protected ?\DateTimeInterface $dateCreated;
17
18
    /**
19
     * Check if the created date has been defined.
20
     *
21
     * @return bool
22
     */
23
    public function hasDateCreated(): bool
24
    {
25
        return isset($this->dateCreated);
26
    }
27
28
    /**
29
     * Return the created date.
30
     *
31
     * @return \DateTimeInterface|null
32
     */
33
    public function getDateCreated(): ?\DateTimeInterface
34
    {
35
        return $this->dateCreated;
36
    }
37
38
    /**
39
     * Set the created date.
40
     *
41
     * @param \DateTimeInterface|null $dateCreated
42
     */
43
    public function setDateCreated(?\DateTimeInterface $dateCreated): void
44
    {
45
        $this->dateCreated = $dateCreated;
46
    }
47
}
48