Passed
Pull Request — feature/publishable (#31)
by Vincent
06:26
created

PublishableTrait::setPublishedResource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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