<?php

declare(strict_types=1);

namespace PpPhp\Core\Designer\Descriptors;

/**
 * ComponentDescriptor
 *
 * Describes the editable properties of a Designer component.
 *
 * The Descriptor Engine allows the Properties panel to be generated from
 * metadata instead of being hardcoded for every component type.
 *
 * @package PPphp
 * @subpackage Designer\Descriptors
 * @since 0.7.1
 */
class ComponentDescriptor
{
    public function __construct(
        private readonly string $type,
        private readonly string $name,
        private readonly string $description,
        private readonly string $icon,
        private readonly array $groups = []
    ) {
    }

    public function type(): string
    {
        return $this->type;
    }

    public function name(): string
    {
        return $this->name;
    }

    public function description(): string
    {
        return $this->description;
    }

    public function icon(): string
    {
        return $this->icon;
    }

    public function groups(): array
    {
        return $this->groups;
    }

    public function toArray(): array
    {
        return [
            'type' => $this->type,
            'name' => $this->name,
            'description' => $this->description,
            'icon' => $this->icon,
            'groups' => $this->groups,
        ];
    }
}
