Test Failed
Pull Request — main (#149)
by Daniel
17:45
created

ResourceMetadata::isInit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components 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\ApiComponentsBundle\Serializer\ResourceMetadata;
15
16
use Silverback\ApiComponentsBundle\Metadata\PageDataMetadata;
17
use Symfony\Component\Serializer\Annotation\Groups;
18
use Symfony\Component\Validator\ConstraintViolationListInterface;
19
20
class ResourceMetadata implements ResourceMetadataInterface
21
{
22
    #[Groups('cwa_resource:metadata')]
23
    private ?PageDataMetadata $pageDataMetadata = null;
24
25
    #[Groups('cwa_resource:metadata')]
26
    private ?string $staticComponent = null;
27
28
    #[Groups('cwa_resource:metadata')]
29
    private ?bool $collection = null;
30
31
    #[Groups('cwa_resource:metadata')]
32
    private ?bool $persisted = null;
33
34
    #[Groups('cwa_resource:metadata')]
35
    private ?ResourcePublishableMetadata $publishable = null;
36
37
    #[Groups('cwa_resource:metadata')]
38
    private ?ConstraintViolationListInterface $violationList;
39
40
    #[Groups('cwa_resource:metadata')]
41
    private ?array $mediaObjects = null;
42
43
    public function isInit(): bool
44
    {
45
        return true;
46
    }
47
48
    public function getResourceMetadata(): ?ResourceMetadataInterface
49
    {
50
        return $this;
51
    }
52
53
    public function getPageDataMetadata(): ?PageDataMetadata
54
    {
55
        return $this->pageDataMetadata;
56
    }
57
58
    public function setPageDataMetadata(PageDataMetadata $pageDataMetadata): void
59
    {
60
        $this->pageDataMetadata = $pageDataMetadata;
61
    }
62
63
    public function getStaticComponent(): ?string
64
    {
65
        return $this->staticComponent;
66
    }
67
68
    public function setStaticComponent(string $staticComponentIri): void
69
    {
70
        $this->staticComponent = $staticComponentIri;
71
    }
72
73
    public function getCollection(): ?bool
74
    {
75
        return $this->collection;
76
    }
77
78
    public function setCollection(bool $collection): void
79
    {
80
        $this->collection = $collection;
81
    }
82
83
    public function getPersisted(): ?bool
84
    {
85
        return $this->persisted;
86
    }
87
88
    public function setPersisted(?bool $persisted): void
89
    {
90
        $this->persisted = $persisted;
91
    }
92
93
    public function getPublishable(): ?ResourcePublishableMetadata
94
    {
95
        return $this->publishable;
96
    }
97
98
    public function setPublishable(bool $published, ?string $publishedAt = null): void
99
    {
100
        if ($this->publishable) {
101
            $this->publishable->published = $published;
102
            $this->publishable->publishedAt = $publishedAt;
103
104
            return;
105
        }
106
        $this->publishable = new ResourcePublishableMetadata($published, $publishedAt);
107
    }
108
109
    public function getViolationList(): ?ConstraintViolationListInterface
110
    {
111
        return $this->violationList;
112
    }
113
114
    public function setViolationList(?ConstraintViolationListInterface $violationList): void
115
    {
116
        $this->violationList = $violationList;
117
    }
118
119
    public function getMediaObjects(): ?array
120
    {
121
        return $this->mediaObjects;
122
    }
123
124
    public function setMediaObjects(array $mediaObjects): void
125
    {
126
        $this->mediaObjects = $mediaObjects;
127
    }
128
}
129