. /** * A class to emulate enum type for attempt state. * * @copyright 2022 onwards Vitaly Potenko * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ declare(strict_types=1); namespace mod_adaptivequiz\local\attempt; final class attempt_state { public const IN_PROGRESS = 'inprogress'; public const COMPLETED = 'complete'; /** * @var string $stateasstring */ private $stateasstring; private function __construct(string $state) { $this->stateasstring = $state; } public function is_in_progress(): bool { return self::IN_PROGRESS === $this->stateasstring; } public function is_completed(): bool { return self::COMPLETED === $this->stateasstring; } public static function in_progress(): self { return new self(self::IN_PROGRESS); } public static function completed(): self { return new self(self::COMPLETED); } }