Test Failed
Push — master ( 9e5b01...b40a06 )
by Daniel
05:29
created

Collection::setDefaultQueryString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 4
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Silverback\ApiComponentBundle\Entity\Component\Collection;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\ORM\Mapping as ORM;
9
use Silverback\ApiComponentBundle\Entity\Component\AbstractComponent;
10
use Symfony\Component\Serializer\Annotation\Groups;
11
use Traversable;
12
13
/**
14
 * @ORM\Entity()
15
 * @author Daniel West <[email protected]>
16
 */
17
class Collection extends AbstractComponent
18
{
19
    /**
20
     * @ORM\Column()
21
     * @Groups({"component", "content"})
22
     * @var string
23
     */
24
    private $resource;
25
26
    /**
27
     * @ORM\Column(type="integer", nullable=true)
28
     * @Groups({"component", "content"})
29
     * @var int|null
30
     */
31
    private $perPage;
32
33
    /**
34
     * @ORM\Column(nullable=true)
35
     * @Groups({"component", "content"})
36
     * @var string|null
37
     */
38
    private $title;
39
40
    /**
41
     * @var array|Traversable
42
     * @Groups({"component_read", "content_read"})
43
     */
44
    private $collection;
45
46
    /**
47
     * @var ArrayCollection
48
     * @Groups({"component_read", "content_read"})
49
     */
50
    private $collectionRoutes;
51
52
    /**
53
     * @ORM\Column(nullable=true)
54
     * @Groups({"component", "content"})
55
     * @var string|null
56
     */
57
    private $defaultQueryString;
58
59
    /**
60
     * Collection constructor.
61
     */
62
    public function __construct()
63
    {
64
        parent::__construct();
65
        $this->collectionRoutes = new ArrayCollection;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getResource(): string
72
    {
73
        return $this->resource;
74
    }
75
76
    /**
77
     * @param string $resource
78
     * @return Collection
79
     */
80
    public function setResource(string $resource): self
81
    {
82
        $this->resource = $resource;
83
        return $this;
84
    }
85
86
    /**
87
     * @return null|int
88
     */
89
    public function getPerPage(): ?int
90
    {
91
        return $this->perPage;
92
    }
93
94
    /**
95
     * @param null|int $perPage
96
     * @return Collection
97
     */
98
    public function setPerPage(?int $perPage): self
99
    {
100
        $this->perPage = $perPage;
101
        return $this;
102
    }
103
104
    /**
105
     * @return null|string
106
     */
107
    public function getTitle(): ?string
108
    {
109
        return $this->title;
110
    }
111
112
    /**
113
     * @param null|string $title
114
     * @return Collection
115
     */
116
    public function setTitle(?string $title): self
117
    {
118
        $this->title = $title;
119
        return $this;
120
    }
121
122
    /**
123
     * @return array|Traversable
124
     */
125
    public function getCollection()
126
    {
127
        return $this->collection;
128
    }
129
130
    /**
131
     * @param array|Traversable $collection
132
     * @return Collection
133
     */
134
    public function setCollection($collection): self
135
    {
136
        $this->collection = $collection;
137
        return $this;
138
    }
139
140
    /**
141
     * @return ArrayCollection|null
142
     */
143
    public function getCollectionRoutes(): ArrayCollection
144
    {
145
        return $this->collectionRoutes;
146
    }
147
148
    /**
149
     * @param string $method
150
     * @param string $route
151
     * @return static
152
     */
153
    public function addCollectionRoute(string $method, string $route)
154
    {
155
        if (!$this->collectionRoutes) {
156
            $this->collectionRoutes = new ArrayCollection;
157
        }
158
        $this->collectionRoutes->set($method, $route);
159
        return $this;
160
    }
161
162
    /**
163
     * @return null|string
164
     */
165
    public function getDefaultQueryString(): ?string
166
    {
167
        return $this->defaultQueryString;
168
    }
169
170
    /**
171
     * @param null|string $defaultQueryString
172
     * @return Collection
173
     */
174
    public function setDefaultQueryString(?string $defaultQueryString): self
175
    {
176
        $this->defaultQueryString = $defaultQueryString;
177
        return $this;
178
    }
179
}
180