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

PublishableTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
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 38
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 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