<?php namespace App\Entity; /** * Entity for workspaces */ class ActorEntity { /** @var string The unique identifier of the entity */ protected $id = ''; /** @var string The first name of the actof */ protected $firstName = ''; /** @var string The last name of the actor */ protected $lastName = ''; /** @var string|null The optional nickname of the actor, if not set, the display name will be Firstname LASTNAME */ protected $nickname = null; /** @var bool If the actor is still active, if set to false, he will not be proposed when setting and actor to a taks or activity */ protected $active = True; /** * Get the unique ID the entity * * @return string */ public function getId(): string { return $this->id; } /** * Set the ID of the entity * <br/> This should not be done after creation * * @param string $id * @return self */ public function setId(string $id): self { $this->id = $id; return $this; } /** * Generate and save a random ID * * @return string Generated ID */ public function generateId(): string { // Generate ID $base = array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')); $id = ""; for ($index = 0; $index < 8; $index ++) { $id .= $base[rand(0, count($base) - 1)]; } // Save and return $this->setId($id); return $id; } /** * Get the first name of the actor * * @return string */ public function getFirstName(): string { return $this->firstName; } /** * Set the first name of the actor * * @param string $firstName * @return self */ public function setFirstName(string $firstName): self { $this->firstName = $firstName; return $this; } /** * Get the last name of the actor * * @return string */ public function getLastName(): string { return $this->lastName; } /** * Set the last name of the actor * * @param string $lastName * @return self */ public function setLastName(string $lastName): self { $this->lastName = $lastName; return $this; } /** * Get the formated version of the full name (Firstname LASTNAME) * * @return string */ public function getFullName(): string { return sprintf('%s %s', ucfirst(strtolower($this->firstName)), strtoupper($this->lastName)); } /** * Get the nickname of the actor * * @return string|null */ public function getNickname(): string { return $this->nickname; } /** * Set the nickname name of the actor * * @param string $nickname * @return self */ public function setNickname(string $nickname): self { $this->nickname = $nickname; return $this; } /** * Get the display name of the actor. Equals nickname if set, Firstname LASTNAME else. * @return string */ public function getDisplayName(): string { return empty($this->nickname) ? $this->getFullName() : $this->nickname; } /** * If the actor is active * * @return bool */ public function getActive(): bool { return $this->active; } /** * Set the active status of the actor * * @param bool $active * @return self */ public function setActive(bool $active): self { $this->active = $active; return $this->active; } }