<?php namespace App\Entity; /** * Entity for workspaces */ class WorkspaceEntity { /** @var string The unique ID the workspace */ protected $id; /** @var string The name of the workspace */ protected $name; /* @var bool Is the workspace still active */ protected $active; /** * Get the unique ID the workspace * @return string */ public function getId(): string { return $this->id; } /** * Set the ID of the workspace * <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 name of the workspace * * @return string */ public function getName(): string { return $this->name; } /** * Set a new name for the workspace * @param string $name * @return self */ public function setName(string $name): self { $this->name = $name; return $this; } /** * If the workspace is active * * @return bool */ public function getActive(): bool { return $this->active; } /** * Set the active status of the workspace * * @param bool $active * @return self */ public function setActive(bool $active): self { $this->active = $active; return $this->active; } }