Newer
Older
activity-manager / src / Entity / ProjectEntity.php
<?php
namespace App\Entity;

use App\Helper\StringGenerationHelper;

/**
 * Entity for projects
 */
class ProjectEntity
{

    /** @var string The unique identifier of the entity */
    protected $id = '';

    /** @var string The name of the project */
    protected $name = '';

    /** @var bool If the project 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
        $id = StringGenerationHelper::generateString(array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')), 8);

        // Save and return
        $this->setId($id);
        return $id;
    }

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

    /**
     * Get the name of the project
     *
     * @param string $name
     * @return self
     */
    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    /**
     * If the project is active
     *
     * @return bool
     */
    public function getActive(): bool
    {
        return $this->active;
    }

    /**
     * Set the active status of the project
     *
     * @param bool $active
     * @return self
     */
    public function setActive(bool $active): self
    {
        $this->active = $active;

        return $this;
    }
}