Skip to content

Commit

Permalink
Generating (UU)IDs in ctors, corrected data types of properties
Browse files Browse the repository at this point in the history
  • Loading branch information
sukovec committed Feb 12, 2018
1 parent bcae021 commit 1154910
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 47 deletions.
27 changes: 8 additions & 19 deletions src/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Event
/**
* @var string
*
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*/
protected $description;

Expand All @@ -39,39 +39,28 @@ class Event
*/
protected $eventType;


/**
* ItemType constructor
*
*/
public function __construct() {
public function __construct(string $title, EventType $eventType) {
$this->id = Uuid::uuid4();
$this->title = $title;
$this->eventType = $eventType;
}

public function getId(): UuidInterface {
return $this->id;
}

/**
* @return string
*/
public function getTitle(): string {
return $this->title;
}

/**
* @param string $title
*/
public function setTitle(string $title): void {
$this->title = $title;
}

/**
* @return EventType
*/
public function getEventType(): EventType {
return $this->eventType;
}

/**
* @param EventType $eventType
*/
public function setEventType(EventType $eventType): void {
$this->eventType = $eventType;
}
Expand Down
26 changes: 8 additions & 18 deletions src/Entity/EventType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php declare(strict_types = 1);

namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
Expand All @@ -25,41 +25,31 @@ class EventType

/**
* @var string|null
* @ORM\Column(type="string", nullable=true)
* @ORM\Column(type="string", nullable=true, length=512)
*/
protected $comment;

/**
* @param string $name
* */
public function __construct(string $name) {
public function __construct(string $name, ?string $comment = null) {
$this->name = $name;
$this->comment = $comment;
}

public function getId(): int {
return $this->id;
}

/**
* @return string
*/
public function getName(): string {
return $this->name;
}

/**
* @param string $name
*/
public function setName(string $name): void {
$this->name = $name;
}

/**
* @return null|string
*/
public function getComment(): ?string {
return $this->comment;
}

/**
* @param null|string $comment
*/
public function setComment(?string $comment): void {
$this->comment = $comment;
}
Expand Down
73 changes: 63 additions & 10 deletions src/Entity/SubEvent.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php declare(strict_types = 1);

namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
Expand All @@ -18,6 +18,12 @@ class SubEvent
*/
protected $id;

/**
* @var Event
*
* @ORM\ManyToOne(targetEntity="Event")
*/
protected $parent;

/**
* @var string
Expand All @@ -29,31 +35,78 @@ class SubEvent
/**
* @var string
*
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*/
protected $description;



/**
* ItemType constructor
/**
* @var \DateTime
*
* @ORM\Column(type="datetimetz")
*/
protected $startDate;

public function __construct() {
$this->id = Uuid::uuid4();
}

/**
* @return string
* @var \DateTime
*
* @ORM\Column(type="datetimetz")
*/
protected $endDate;

public function __construct(Event $parent, string $title, string $description, \DateTime $startDate, \DateTime $endDate) {
$this->id = Uuid::uuid4();
$this->parent = $parent;
$this->title = $title;
$this->description = $description;
$this->startDate = $startDate;
$this->endDate = $endDate;
}

public function getId(): UuidInterface {
return $this->id;
}

public function getParent(): Event {
return $this->parent;
}

public function setParent(Event $parent): void {
$this->parent = $parent;
}

public function getTitle(): string {
return $this->title;
}

/**
* @param string $title
*/
public function setTitle(string $title): void {
$this->title = $title;
}

public function getDescription(): string {
return $this->description;
}

public function setDescription(string $description): void {
$this->description = $description;
}

public function getStartDate(): \DateTime {
return $this->startDate;
}

public function setStartDate(\DateTime $startDate): void {
$this->startDate = $startDate;
}

public function getEndDate(): \DateTime {
return $this->endDate;
}

public function setEndDate(\DateTime $endDate): void {
$this->endDate = $endDate;
}
}

0 comments on commit 1154910

Please sign in to comment.