Passed
Pull Request — feature/publishable (#31)
by Vincent
05:42
created

PublishableTrait::getPublishedResource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Component 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\ApiComponentBundle\Entity\Utility;
15
16
use Doctrine\ORM\Mapping as ORM;
17
use Symfony\Component\Validator\Constraints as Assert;
18
19
/**
20
 * @author Vincent Chalamon <[email protected]>
21
 */
22
trait PublishableTrait
23
{
24
    /**
25
     * @ORM\Column(type="date")
26
     * @Assert\NotNull
27
     */
28
    private ?\DateTimeInterface $publishedAt = null;
29
30
    private ?self $publishedResource = null;
31
32
    /** @return static */
33
    public function setPublishedAt(?\DateTimeInterface $publishedAt)
34
    {
35
        $this->publishedAt = $publishedAt;
36
37
        return $this;
38
    }
39
40
    public function getPublishedAt(): ?\DateTimeInterface
41
    {
42
        return $this->publishedAt;
43
    }
44
45
    public function isPublished(): bool
46
    {
47
        return null !== $this->publishedAt;
48
    }
49
50
    /** @return static */
51
    public function setPublishedResource($publishedResource)
52
    {
53
        $this->publishedResource = $publishedResource;
54
55
        return $this;
56
    }
57
58
    public function getPublishedResource(): ?self
59
    {
60
        return $this->publishedResource;
61
    }
62
}
63