Passed
Pull Request — main (#155)
by Daniel
05:05
created

ResourceMetadata   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Test Coverage

Coverage 10.53%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 38
dl 0
loc 118
ccs 4
cts 38
cp 0.1053
rs 10
c 2
b 0
f 0
wmc 18

17 Methods

Rating   Name   Duplication   Size   Complexity  
A getCollection() 0 3 1
A getStaticComponent() 0 3 1
A setStaticComponent() 0 3 1
A getPublishable() 0 3 1
A getPageDataMetadata() 0 3 1
A setPageDataMetadata() 0 3 1
A setMediaObjects() 0 3 1
A setPersisted() 0 3 1
A setPageDataPath() 0 3 1
A setViolationList() 0 3 1
A getPageDataPath() 0 3 1
A getViolationList() 0 3 1
A setPublishable() 0 9 2
A getMediaObjects() 0 3 1
A getPersisted() 0 3 1
A setCollection() 0 3 1
A getResourceMetadata() 0 3 1
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
    // for page data
23
    #[Groups('cwa_resource:metadata')]
24
    private ?PageDataMetadata $pageDataMetadata = null;
25
26
    // for component position
27
    #[Groups('cwa_resource:metadata')]
28
    private ?string $staticComponent = null;
29
30
    // for component position
31
    #[Groups('cwa_resource:metadata')]
32
    private ?string $pageDataPath = null;
33
34
    #[Groups('cwa_resource:metadata')]
35
    private ?bool $collection = null;
36
37
    #[Groups('cwa_resource:metadata')]
38
    private ?bool $persisted = null;
39
40
    #[Groups('cwa_resource:metadata')]
41
    private ?ResourcePublishableMetadata $publishable = null;
42
43
    #[Groups('cwa_resource:metadata')]
44
    private ?ConstraintViolationListInterface $violationList;
45
46
    #[Groups('cwa_resource:metadata')]
47
    private ?array $mediaObjects = null;
48
49
    public function getResourceMetadata(): ?ResourceMetadataInterface
50
    {
51
        return $this;
52
    }
53
54
    public function getPageDataMetadata(): ?PageDataMetadata
55
    {
56
        return $this->pageDataMetadata;
57
    }
58
59
    public function setPageDataMetadata(PageDataMetadata $pageDataMetadata): void
60
    {
61
        $this->pageDataMetadata = $pageDataMetadata;
62
    }
63
64
    public function getStaticComponent(): ?string
65
    {
66
        return $this->staticComponent;
67
    }
68
69
    public function setStaticComponent(string $staticComponentIri): void
70
    {
71
        $this->staticComponent = $staticComponentIri;
72
    }
73
74
    public function getPageDataPath(): ?string
75
    {
76
        return $this->pageDataPath;
77
    }
78
79
    public function setPageDataPath(?string $pageDataPath): void
80
    {
81
        $this->pageDataPath = $pageDataPath;
82
    }
83
84
    public function getCollection(): ?bool
85
    {
86
        return $this->collection;
87
    }
88
89
    public function setCollection(bool $collection): void
90
    {
91
        $this->collection = $collection;
92
    }
93
94 1
    public function getPersisted(): ?bool
95
    {
96 1
        return $this->persisted;
97
    }
98
99 1
    public function setPersisted(?bool $persisted): void
100
    {
101 1
        $this->persisted = $persisted;
102
    }
103
104
    public function getPublishable(): ?ResourcePublishableMetadata
105
    {
106
        return $this->publishable;
107
    }
108
109
    public function setPublishable(bool $published, ?string $publishedAt = null): void
110
    {
111
        if ($this->publishable) {
112
            $this->publishable->published = $published;
113
            $this->publishable->publishedAt = $publishedAt;
114
115
            return;
116
        }
117
        $this->publishable = new ResourcePublishableMetadata($published, $publishedAt);
118
    }
119
120
    public function getViolationList(): ?ConstraintViolationListInterface
121
    {
122
        return $this->violationList;
123
    }
124
125
    public function setViolationList(?ConstraintViolationListInterface $violationList): void
126
    {
127
        $this->violationList = $violationList;
128
    }
129
130
    public function getMediaObjects(): ?array
131
    {
132
        return $this->mediaObjects;
133
    }
134
135
    public function setMediaObjects(array $mediaObjects): void
136
    {
137
        $this->mediaObjects = $mediaObjects;
138
    }
139
}
140