Skip to content

Commit 1154910

Browse files
committed
Generating (UU)IDs in ctors, corrected data types of properties
1 parent bcae021 commit 1154910

3 files changed

Lines changed: 79 additions & 47 deletions

File tree

src/Entity/Event.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Event
2929
/**
3030
* @var string
3131
*
32-
* @ORM\Column(type="string")
32+
* @ORM\Column(type="text")
3333
*/
3434
protected $description;
3535

@@ -39,39 +39,28 @@ class Event
3939
*/
4040
protected $eventType;
4141

42-
43-
/**
44-
* ItemType constructor
45-
*
46-
*/
47-
public function __construct() {
42+
public function __construct(string $title, EventType $eventType) {
4843
$this->id = Uuid::uuid4();
44+
$this->title = $title;
45+
$this->eventType = $eventType;
46+
}
47+
48+
public function getId(): UuidInterface {
49+
return $this->id;
4950
}
5051

51-
/**
52-
* @return string
53-
*/
5452
public function getTitle(): string {
5553
return $this->title;
5654
}
5755

58-
/**
59-
* @param string $title
60-
*/
6156
public function setTitle(string $title): void {
6257
$this->title = $title;
6358
}
6459

65-
/**
66-
* @return EventType
67-
*/
6860
public function getEventType(): EventType {
6961
return $this->eventType;
7062
}
7163

72-
/**
73-
* @param EventType $eventType
74-
*/
7564
public function setEventType(EventType $eventType): void {
7665
$this->eventType = $eventType;
7766
}

src/Entity/EventType.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php declare(strict_types = 1);
22

33
namespace App\Entity;
44
use Doctrine\ORM\Mapping as ORM;
@@ -25,41 +25,31 @@ class EventType
2525

2626
/**
2727
* @var string|null
28-
* @ORM\Column(type="string", nullable=true)
28+
* @ORM\Column(type="string", nullable=true, length=512)
2929
*/
3030
protected $comment;
3131

32-
/**
33-
* @param string $name
34-
* */
35-
public function __construct(string $name) {
32+
public function __construct(string $name, ?string $comment = null) {
3633
$this->name = $name;
34+
$this->comment = $comment;
35+
}
36+
37+
public function getId(): int {
38+
return $this->id;
3739
}
3840

39-
/**
40-
* @return string
41-
*/
4241
public function getName(): string {
4342
return $this->name;
4443
}
4544

46-
/**
47-
* @param string $name
48-
*/
4945
public function setName(string $name): void {
5046
$this->name = $name;
5147
}
5248

53-
/**
54-
* @return null|string
55-
*/
5649
public function getComment(): ?string {
5750
return $this->comment;
5851
}
5952

60-
/**
61-
* @param null|string $comment
62-
*/
6353
public function setComment(?string $comment): void {
6454
$this->comment = $comment;
6555
}

src/Entity/SubEvent.php

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php declare(strict_types = 1);
22

33
namespace App\Entity;
44
use Doctrine\ORM\Mapping as ORM;
@@ -18,6 +18,12 @@ class SubEvent
1818
*/
1919
protected $id;
2020

21+
/**
22+
* @var Event
23+
*
24+
* @ORM\ManyToOne(targetEntity="Event")
25+
*/
26+
protected $parent;
2127

2228
/**
2329
* @var string
@@ -29,31 +35,78 @@ class SubEvent
2935
/**
3036
* @var string
3137
*
32-
* @ORM\Column(type="string")
38+
* @ORM\Column(type="text")
3339
*/
3440
protected $description;
3541

36-
37-
38-
/**
39-
* ItemType constructor
42+
/**
43+
* @var \DateTime
4044
*
45+
* @ORM\Column(type="datetimetz")
4146
*/
47+
protected $startDate;
48+
4249
public function __construct() {
4350
$this->id = Uuid::uuid4();
4451
}
4552

4653
/**
47-
* @return string
54+
* @var \DateTime
55+
*
56+
* @ORM\Column(type="datetimetz")
4857
*/
58+
protected $endDate;
59+
60+
public function __construct(Event $parent, string $title, string $description, \DateTime $startDate, \DateTime $endDate) {
61+
$this->id = Uuid::uuid4();
62+
$this->parent = $parent;
63+
$this->title = $title;
64+
$this->description = $description;
65+
$this->startDate = $startDate;
66+
$this->endDate = $endDate;
67+
}
68+
69+
public function getId(): UuidInterface {
70+
return $this->id;
71+
}
72+
73+
public function getParent(): Event {
74+
return $this->parent;
75+
}
76+
77+
public function setParent(Event $parent): void {
78+
$this->parent = $parent;
79+
}
80+
4981
public function getTitle(): string {
5082
return $this->title;
5183
}
5284

53-
/**
54-
* @param string $title
55-
*/
5685
public function setTitle(string $title): void {
5786
$this->title = $title;
5887
}
88+
89+
public function getDescription(): string {
90+
return $this->description;
91+
}
92+
93+
public function setDescription(string $description): void {
94+
$this->description = $description;
95+
}
96+
97+
public function getStartDate(): \DateTime {
98+
return $this->startDate;
99+
}
100+
101+
public function setStartDate(\DateTime $startDate): void {
102+
$this->startDate = $startDate;
103+
}
104+
105+
public function getEndDate(): \DateTime {
106+
return $this->endDate;
107+
}
108+
109+
public function setEndDate(\DateTime $endDate): void {
110+
$this->endDate = $endDate;
111+
}
59112
}

0 commit comments

Comments
 (0)