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 | */ |
||
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 | * inverseJoinColumns={@ORM\JoinColumn(name="image_name", referencedColumnName="name", unique=true)} |
||
65 | * ) |
||
66 | */ |
||
67 | private $images; |
||
68 | |||
69 | 2 | public function __construct( |
|
70 | string $name, |
||
71 | User $creator, |
||
72 | \DateTime $date, |
||
73 | string $description |
||
74 | ) |
||
75 | { |
||
76 | 2 | $this->name = $name; |
|
77 | 2 | $this->creator = $creator; |
|
78 | 2 | $this->date = $date; |
|
79 | 2 | $this->description = $description; |
|
80 | 2 | $this->id = HashGenerator::generate(); |
|
|
|||
81 | 2 | $this->images = new ArrayCollection(); |
|
82 | 2 | } |
|
83 | |||
84 | 6 | public function getDate(): string |
|
88 | |||
89 | 10 | public function getId(): string |
|
93 | |||
94 | 1 | public function setDate(\DateTime $date) |
|
98 | |||
99 | 6 | public function getName(): string |
|
103 | |||
104 | 1 | public function setName(string $name) |
|
108 | |||
109 | 6 | public function getDescription(): string |
|
113 | |||
114 | 1 | public function setDescription(string $description) |
|
118 | |||
119 | /** |
||
120 | * @return Image[]|PersistentCollection |
||
121 | */ |
||
122 | 7 | public function getImages() |
|
126 | |||
127 | /** |
||
128 | * @return Image|null |
||
129 | */ |
||
130 | 1 | public function getImageWithName(string $imageName) |
|
140 | |||
141 | 2 | public function addImage(Image $image) |
|
145 | |||
146 | 1 | 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.