Completed
Pull Request — master (#162)
by
unknown
03:18
created

VenueSector   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 159
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 39.29%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 159
ccs 11
cts 28
cp 0.3929
rs 10
c 1
b 0
f 0
wmc 11
lcom 2
cbo 2

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A unsetTranslations() 0 6 1
A getTitle() 0 4 1
A setTitle() 0 6 1
A getVenue() 0 4 1
A addSeat() 0 6 1
A removeSeat() 0 4 1
A getSeat() 0 4 1
A getSlug() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
use Gedmo\Translatable\Document\Translation;
10
use JMS\Serializer\Annotation\ExclusionPolicy;
11
use JMS\Serializer\Annotation\Expose;
12
use JMS\Serializer\Annotation\Type;
13
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface;
14
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable;
15
use Symfony\Component\Validator\Constraints as Assert;
16
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
17
18
/**
19
 * @ORM\Table(name="venue_sector")
20
 * @ORM\Entity(repositoryClass="AppBundle\Repository\VenueSectorRepository")
21
 * @UniqueEntity(fields={"venue", "slug"})
22
 * @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\VenueSectorTranslation")
23
 * @ExclusionPolicy("all")
24
 */
25
class VenueSector extends AbstractPersonalTranslatable implements TranslatableInterface
26
{
27
    /**
28
     * @var integer
29
     *
30
     * @ORM\Column(name="id", type="integer")
31
     * @ORM\Id
32
     * @ORM\GeneratedValue(strategy="AUTO")
33
     * @Type("integer")
34
     * @Expose()
35
     */
36
    protected $id;
37
38
    /**
39
     * @var string
40
     * @Gedmo\Translatable
41
     * @Assert\NotBlank()
42
     * @ORM\Column(type="string", length=255)
43
     * @Type("string")
44
     * @Expose()
45
     */
46
    protected $title;
47
48
    /**
49
     * @var ArrayCollection|Translation[]
50
     *
51
     * @ORM\OneToMany(
52
     *     targetEntity="AppBundle\Entity\Translations\VenueSectorTranslation",
53
     *     mappedBy="object",
54
     *     cascade={"persist", "remove"}
55
     * )
56
     */
57
    protected $translations;
58
59
    /**
60
     * @var Venue
61
     *
62
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Venue", inversedBy="venueSectors")
63
     */
64
    protected $venue;
65
66
    /**
67
     * @var Collection|Seat[]
68
     *
69
     * @ORM\OneToMany(
70
     *     targetEntity="AppBundle\Entity\Seat",
71
     *     mappedBy="venueSector",
72
     *     cascade={"persist", "remove"}
73
     * )
74
     */
75
    protected $seats;
76
77
    /**
78
     * @Gedmo\Slug(fields={"title"})
79
     * @ORM\Column(name="slug", type="string", length=255)
80
     * @Type("string")
81
     * @Expose
82
     */
83
    private $slug;
84
85
    /**
86
     * VenueSector constructor.
87
     */
88
    public function __construct()
89
    {
90
        parent::__construct();
91
        $this->seats = new ArrayCollection();
92
    }
93
94
    /**
95
     * @return integer
96
     */
97 6
    public function getId()
98
    {
99 6
        return $this->id;
100
    }
101
102
    /**
103
     * @return VenueSector
104
     */
105 1
    public function unsetTranslations()
106
    {
107 1
        $this->translations = null;
108
109 1
        return $this;
110
    }
111
112
    /**
113
     * @return string
114
     */
115 3
    public function getTitle()
116
    {
117 3
        return $this->title;
118
    }
119
120
    /**
121
     * @param  string $title
122
     * @return VenueSector
123
     */
124
    public function setTitle($title)
125
    {
126
        $this->title = $title;
127
128
        return $this;
129
    }
130
131
    /**
132
     * @return Venue
133
     */
134 2
    public function getVenue()
135
    {
136 2
        return $this->venue;
137
    }
138
139
    /**
140
     * @param  Seat $seat
141
     * @return VenueSector
142
     */
143
    public function addSeat(Seat $seat)
144
    {
145
        $this->seats[] = $seat;
146
147
        return $this;
148
    }
149
150
    /**
151
     * @param Seat $seat
152
     */
153
    public function removeSeat(Seat $seat)
154
    {
155
        $this->seats->removeElement($seat);
156
    }
157
158
    /**
159
     * @return Collection
160
     */
161
    public function getSeat()
162
    {
163
        return $this->seats;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->seats; of type Doctrine\Common\Collecti...AppBundle\Entity\Seat[] adds the type AppBundle\Entity\Seat[] to the return on line 163 which is incompatible with the return type documented by AppBundle\Entity\VenueSector::getSeat of type Doctrine\Common\Collections\Collection.
Loading history...
164
    }
165
166
    /**
167
     * Get slug
168
     *
169
     * @return string
170
     */
171
    public function getSlug()
172
    {
173
        return $this->slug;
174
    }
175
176
    /**
177
     * @return string
178
     */
179 2
    public function __toString()
180
    {
181 2
        return $this->getTitle().' '.$this->getVenue();
182
    }
183
}
184