Improved public API in Tag entity, avoiding anemic model

This commit is contained in:
Alejandro Celaya
2018-10-28 14:38:43 +01:00
parent f7ceeff05a
commit 084b1169d7
11 changed files with 23 additions and 25 deletions

View File

@@ -24,24 +24,23 @@ class Tag extends AbstractEntity implements JsonSerializable
*/
private $name;
public function __construct($name = null)
public function __construct(string $name)
{
$this->name = $name;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name)
public function rename(string $name): void
{
$this->name = $name;
return $this;
}
public function jsonSerialize(): string
{
return $this->name;
}
public function __toString(): string
{
return $this->name;
}
}