. */ namespace SP\Mvc\View\Components; use JsonSerializable; use SP\Domain\Common\Models\ItemWithIdAndNameModel; /** * Class SelectItem */ final class SelectItem implements JsonSerializable { protected bool $selected = false; protected bool $skip = false; public function __construct( protected readonly int|string $id, protected readonly string $name, protected readonly ?ItemWithIdAndNameModel $item = null ) { } /** * @return int|string */ public function getId(): int|string { return $this->id; } public function getName(): string { return $this->name; } public function isSelected(): bool { return $this->selected; } public function setSelected(bool $selected): void { $this->selected = $selected; } /** * @param string $property * * @return mixed */ public function getItemProperty(string $property): mixed { return $this->item?->{$property}; } public function isSkip(): bool { return $this->skip; } public function setSkip(bool $skip): void { $this->skip = $skip; } /** * @inheritDoc */ public function jsonSerialize(): array { return ['id' => $this->id, 'name' => $this->name]; } }