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

PublishableTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 10
c 1
b 0
f 0
dl 0
loc 39
ccs 0
cts 12
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPublishedResource() 0 3 1
A isPublished() 0 3 1
A setPublishedAt() 0 5 1
A setPublishedResource() 0 5 1
A getPublishedAt() 0 3 1
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