29 lines
693 B
PHP
29 lines
693 B
PHP
<?php
|
|
|
|
namespace Lucent\Schema\Sidebar;
|
|
|
|
use Lucent\Schema\Sidebar\Item\Item;
|
|
use Lucent\Schema\Sidebar\Item\LinkItem;
|
|
use Lucent\Schema\Sidebar\Item\SchemaItem;
|
|
use Lucent\Support\Collection;
|
|
|
|
class Section
|
|
{
|
|
/**
|
|
* @param Collection<Item> $items
|
|
*/
|
|
public function __construct(
|
|
public string $label,
|
|
public Collection $items
|
|
)
|
|
{
|
|
}
|
|
|
|
public static function fromArray(array $data): self
|
|
{
|
|
return new self(
|
|
label: $data["label"],
|
|
items: (new Collection($data["items"]))->map(fn($itemData) => isset($itemData["schema"]) ? SchemaItem::fromArray($itemData) : LinkItem::fromArray($itemData))
|
|
);
|
|
}
|
|
} |