enforce element level hierarchy

This commit is contained in:
Yisroel Baum 2026-08-11 22:50:07 +03:00
parent 25495b6c4d
commit 99e1ba051c
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
5 changed files with 80 additions and 44 deletions

View file

@ -3,14 +3,14 @@
namespace App\Element;
use App\Set\Set;
use App\Set\SetLevel;
final readonly class Element
{
public function __construct(
private int $id,
private string $name,
private string $kind,
private Set $set,
private SetLevel $level,
private ?Element $parentElement,
private int $position,
) {}
@ -27,12 +27,17 @@ final readonly class Element
public function getKind(): string
{
return $this->kind;
return $this->level->getKind();
}
public function getLevel(): SetLevel
{
return $this->level;
}
public function getSet(): Set
{
return $this->set;
return $this->level->getSet();
}
public function getParentElement(): ?Element