1 | <?php |
||
17 | class Event |
||
18 | { |
||
19 | |||
20 | use CreatorLoginTrait; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | * @ORM\Column(name="id", type="string", length=8) |
||
25 | * @ORM\Id |
||
26 | */ |
||
27 | private $id; |
||
28 | |||
29 | /** |
||
30 | * @var \DateTime |
||
31 | * @ORM\Column(name="date", type="datetime") |
||
32 | */ |
||
33 | private $date; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | * @ORM\Column(name="name", type="string", length=255) |
||
38 | */ |
||
39 | private $name; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | * @ORM\Column(name="description", type="text") |
||
44 | */ |
||
45 | private $description; |
||
46 | |||
47 | /** |
||
48 | * @var User |
||
49 | * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="events") |
||
50 | * @ORM\JoinColumn(name="creator", referencedColumnName="login") |
||
51 | */ |
||
52 | private $creator; |
||
53 | |||
54 | /** |
||
55 | * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Image") |
||
56 | * @ORM\JoinColumn(name="image_id", referencedColumnName="id") |
||
57 | 2 | */ |
|
58 | |||
59 | /** |
||
60 | * @var Image[]|ArrayCollection |
||
61 | * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Image", orphanRemoval=true) |
||
62 | * @ORM\JoinTable(name="event_images", |
||
63 | * joinColumns={@ORM\JoinColumn(name="event_id", referencedColumnName="id")}, |
||
64 | 2 | * inverseJoinColumns={@ORM\JoinColumn(name="image_id", referencedColumnName="id", unique=true)} |
|
65 | 2 | * ) |
|
66 | 2 | */ |
|
67 | 2 | private $images; |
|
68 | 2 | ||
69 | 2 | public function __construct( |
|
83 | 1 | ||
84 | 1 | public function getDate(): string |
|
88 | 1 | ||
89 | 1 | public function getId(): string |
|
93 | 1 | ||
94 | 1 | public function setDate(\DateTime $date) |
|
98 | |||
99 | public function getName(): string |
||
103 | |||
104 | public function setName(string $name) |
||
108 | |||
109 | public function getDescription(): string |
||
113 | |||
114 | public function setDescription(string $description) |
||
118 | |||
119 | /** |
||
120 | * @return Image[]|PersistentCollection |
||
121 | */ |
||
122 | public function getImages() |
||
126 | |||
127 | /** |
||
128 | * @return Image|null |
||
129 | */ |
||
130 | public function getImageWithName(string $imageName) |
||
131 | { |
||
132 | $criteria = Criteria::create()->where(Criteria::expr()->eq('name', $imageName)); |
||
133 | $criteria->setMaxResults(1); |
||
134 | |||
135 | /** @var ArrayCollection $imagesCollection */ |
||
136 | $imagesCollection = $this->images->matching($criteria); |
||
137 | |||
138 | return $imagesCollection->first() ?: null; |
||
139 | } |
||
140 | |||
141 | public function addImage(Image $image) |
||
145 | |||
146 | public function removeImage(Image $image) |
||
150 | } |
||
151 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.