<?php

namespace AutoAdmin\Bundle\Tests\Functional\Model;

use DateTime;

class BrickModel
{
    public function __construct(
        public ?int $id = null,
        public ?string $type = null,
        public ?bool $enabled = null,
        public ?array $settings = null,
        public ?DateTime $createdAt = null,
        public ?DateTime $updatedAt = null,
        /** @var BrickModel[] $children */
        public ?array $children = null,
    ) {
    }

    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'type' => $this->type,
            'enabled' => $this->enabled,
            'settings' => $this->settings,
            'createdAt' => $this->createdAt,
            'updatedAt' => $this->updatedAt,
            'children' => array_map(fn(BrickModel $brick) => $brick->toArray(), $this->children ?? []),
        ];
    }
}
