Completed
Pull Request — master (#191)
by Serhii
02:32
created

History   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 196
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 3

Test Coverage

Coverage 61.29%

Importance

Changes 0
Metric Value
wmc 13
lcom 3
cbo 3
dl 0
loc 196
ccs 19
cts 31
cp 0.6129
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A unsetTranslations() 0 6 1
A setDateTime() 0 6 1
A getDateTime() 0 4 1
A getYear() 0 4 1
A __construct() 0 5 1
A getId() 0 4 1
A addGalleryHasMedion() 0 6 1
A addGalleryHasMedia() 0 4 1
A removeGalleryHasMedion() 0 4 1
A getGalleryHasMedia() 0 4 1
A getType() 0 4 1
A setType() 0 6 1
A getTypes() 0 4 1
1
<?php
2
3
namespace App\Entity;
4
5
use App\Traits\DeletedByTrait;
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
use JMS\Serializer\Annotation as Serializer;
9
use Symfony\Component\Validator\Constraints as Assert;
10
11
/**
12
 * @ORM\Table(name="history")
13
 * @ORM\Entity(repositoryClass="App\Repository\HistoryRepository")
14
 * @Gedmo\TranslationEntity(class="App\Entity\Translations\HistoryTranslation")
15
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
16
 * @Serializer\ExclusionPolicy("all")
17
 */
18
class History extends AbstractTranslateableStory
19
{
20
    use DeletedByTrait;
21
22
    /**
23
     * @var integer
24
     *
25
     * @ORM\Column(name="id", type="integer")
26
     * @ORM\Id
27
     * @ORM\GeneratedValue(strategy="AUTO")
28
     */
29
    protected $id;
30
31
    /**
32
     * @var /Datetime
33
     *
34
     * @Assert\NotBlank()
35
     * @ORM\Column(type="datetime")
36
     * @Serializer\Type("DateTime")
37
     */
38
    protected $dateTime;
39
40
    /**
41
     * @var int
42
     *
43
     * @Serializer\Type("integer")
44
     * @Serializer\Expose
45
     * @Serializer\Accessor(getter="getYear")
46
     */
47
    protected $year;
48
49
    /**
50
     * @var \Doctrine\Common\Collections\Collection
51
     *
52
     * @ORM\OneToMany(
53
     *     targetEntity="App\Entity\Translations\HistoryTranslation",
54
     *     mappedBy="object",
55
     *     cascade={"persist", "remove"}
56
     * )
57
     */
58
    protected $translations;
59
60
    /**
61
     * @var \App\Entity\GalleryHasMedia
62
     *
63
     * @ORM\ManyToMany(targetEntity="App\Entity\GalleryHasMedia", cascade={"persist"})
64
     * @ORM\JoinTable(name="history_galleryHasMedia",
65
     *     joinColumns={@ORM\JoinColumn(name="history_id",referencedColumnName="id")},
66
     *     inverseJoinColumns={@ORM\JoinColumn(name="galleryHasMedia_id",referencedColumnName="id")}
67
     * )
68
     */
69
    protected $galleryHasMedia;
70
71
    /**
72
     * @var string
73
     *
74
     * @Assert\NotBlank()
75
     * @Assert\Choice(callback = "getTypes", message = "choose_valid_type")
76
     * @ORM\Column(type="string", length=255)
77
     * @Serializer\Type("string")
78
     * @Serializer\Expose
79
     */
80
    protected $type;
81
82
    /**
83
     * @var \Doctrine\Common\Collections\Collection
84
     *
85
     * @Serializer\Expose
86
     * @ORM\OneToMany(targetEntity="App\Entity\Performance", mappedBy="festival", orphanRemoval=true)
87
     */
88
    protected $performances;
89
90
    /**
91
     * Constructor
92
     */
93 1
    public function __construct()
94
    {
95 1
        parent::__construct();
96 1
        $this->galleryHasMedia = new \Doctrine\Common\Collections\ArrayCollection();
97 1
    }
98
99
    /**
100
     * Get id
101
     *
102
     * @return integer
103
     */
104 2
    public function getId()
105
    {
106 2
        return $this->id;
107
    }
108
109
    /**
110
     * Unset translations
111
     *
112
     * @return History
113
     */
114 2
    public function unsetTranslations()
115
    {
116 2
        $this->translations = null;
117
118 2
        return $this;
119
    }
120
121
    /**
122
     * Set dateTime
123
     *
124
     * @param  \DateTime $dateTime
125
     * @return History
126
     */
127
    public function setDateTime($dateTime)
128
    {
129
        $this->dateTime = $dateTime;
130
131
        return $this;
132
    }
133
134
    /**
135
     * Get dateTime
136
     *
137
     * @return \DateTime
138
     */
139 5
    public function getDateTime()
140
    {
141 5
        return $this->dateTime;
142
    }
143
144
    /**
145
     * @return mixed
146
     */
147 4
    public function getYear()
148
    {
149 4
        return $this->getDateTime()->format('Y');
150
    }
151
152
    /**
153
     * Add galleryHasMedia
154
     *
155
     * @param \App\Entity\GalleryHasMedia $galleryHasMedia
156
     * @return self
157
     */
158
    public function addGalleryHasMedion(\App\Entity\GalleryHasMedia $galleryHasMedia)
159
    {
160
        $this->galleryHasMedia[] = $galleryHasMedia;
161
162
        return $this;
163
    }
164
165
    public function addGalleryHasMedia(\App\Entity\GalleryHasMedia $galleryHasMedia)
166
    {
167
        return $this->addGalleryHasMedion($galleryHasMedia);
168
    }
169
170
    /**
171
     * Remove galleryHasMedia
172
     *
173
     * @param \App\Entity\GalleryHasMedia $galleryHasMedia
174
     */
175
    public function removeGalleryHasMedion(\App\Entity\GalleryHasMedia $galleryHasMedia)
176
    {
177
        $this->galleryHasMedia->removeElement($galleryHasMedia);
0 ignored issues
show
Bug introduced by
The method removeElement() does not seem to exist on object<App\Entity\GalleryHasMedia>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
178
    }
179
180 3
    /**
181
     * Get galleryHasMedia
182 3
     *
183
     * @return \Doctrine\Common\Collections\Collection
184
     */
185
    public function getGalleryHasMedia()
186
    {
187
        return $this->galleryHasMedia;
188 3
    }
189
190 3
    /**
191
     * @return string
192
     */
193
    public function getType()
194
    {
195
        return $this->type;
196
    }
197
198
    /**
199
     * @param string $type
200
     * @return $this
201
     */
202
    public function setType($type)
203
    {
204 2
        $this->type = $type;
205
206 2
        return $this;
207
    }
208
209
    public static function getTypes()
210
    {
211
        return ['history' => 'history', 'festival' => 'festival'];
212
    }
213
}
214