From 1c376852cd0277866cbb7345ea00993f0b37ad76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 4 Oct 2022 07:31:23 +0200 Subject: [PATCH] Rename title to name Add type member Concat name and type in string representation Pass name and type to constructor --- Entity/Dance.php | 52 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/Entity/Dance.php b/Entity/Dance.php index c269f32..dccee33 100644 --- a/Entity/Dance.php +++ b/Entity/Dance.php @@ -26,7 +26,12 @@ class Dance { /** * @var string */ - protected $title; + protected $name; + + /** + * @var string + */ + protected $type; /** * @var \DateTime @@ -50,9 +55,14 @@ class Dance { /** * Constructor + * + * @param string $name The dance name + * @param string $type The dance type */ - public function __construct() { + public function __construct(string $name, string $type) { //Set defaults + $this->name = $name; + $this->type = $type; $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); @@ -71,25 +81,47 @@ class Dance { } /** - * Set title + * Set name + * + * @param string $name + * + * @return Dance + */ + public function setName(string $name): Dance { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName(): string { + return $this->name; + } + + /** + * Set type * - * @param string $title + * @param string $type * * @return Dance */ - public function setTitle(string $title): Dance { - $this->title = $title; + public function setType(string $type): Dance { + $this->type = $type; return $this; } /** - * Get title + * Get type * * @return string */ - public function getTitle(): string { - return $this->title; + public function getType(): string { + return $this->type; } /** @@ -219,6 +251,6 @@ class Dance { * @return string */ public function __toString(): string { - return $this->title; + return $this->name.' '.lcfirst($this->type); } } -- 2.41.0