for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Chubbyphp\ApiSkeleton\Model;
use Chubbyphp\Model\ModelInterface;
use Ramsey\Uuid\Uuid;
final class Course implements ModelInterface
{
/**
* @var string
*/
private $id;
private $name;
* @var int
private $level;
const LEVEL_START = 1;
const LEVEL_MEDIUM = 2;
const LEVEL_ADVANCED = 3;
const LEVEL_EXPERT = 4;
const LEVEL = [
self::LEVEL_START,
self::LEVEL_MEDIUM,
self::LEVEL_ADVANCED,
self::LEVEL_EXPERT,
];
* @var float
private $progress;
* @var bool
private $active;
private function __construct()
}
* @param string|null $id
*
* @return self
public static function create(string $id = null): self
$self = new self();
$self->id = $id ?? (string) Uuid::uuid4();
return $self;
* @param array $data
* @return self|ModelInterface
public static function fromPersistence(array $data): ModelInterface
$self->id = $data['id'];
$self->name = $data['name'];
$self->level = (int) $data['level'];
$self->progress = (float) $data['progress'];
$self->active = (bool) $data['active'];
* @return array
public function toPersistence(): array
return [
'id' => $this->id,
'name' => $this->name,
'level' => $this->level,
'progress' => $this->progress,
'active' => $this->active,
* @return string
public function getId(): string
return $this->id;
public function getName(): string
return $this->name;
* @param string $name
public function setName(string $name): self
$this->name = $name;
return $this;
* @return int
public function getLevel(): int
return $this->level;
* @param int $level
public function setLevel(int $level): self
$this->level = $level;
* @return float
public function getProgress(): float
return $this->progress;
* @param float $progress
public function setProgress(float $progress): self
$this->progress = $progress;
* @return bool
public function isActive(): bool
return $this->active;
* @param bool $active
public function setActive(bool $active): self
$this->active = $active;