<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\DI\Reflection;

final class ParameterMetadata
{
    public function __construct(
        private readonly string $name,
        private readonly ?string $type,
        private readonly bool $allowsNull,
        private readonly bool $hasDefault,
        private readonly mixed $defaultValue = null,
        private readonly bool $builtin = false
    ) {}

    public function name(): string { return $this->name; }
    public function type(): ?string { return $this->type; }
    public function allowsNull(): bool { return $this->allowsNull; }
    public function hasDefault(): bool { return $this->hasDefault; }
    public function defaultValue(): mixed { return $this->defaultValue; }
    public function builtin(): bool { return $this->builtin; }

    public function toArray(): array
    {
        return [
            'name' => $this->name,
            'type' => $this->type,
            'allowsNull' => $this->allowsNull,
            'hasDefault' => $this->hasDefault,
            'defaultValue' => $this->hasDefault ? $this->defaultValue : null,
            'builtin' => $this->builtin,
        ];
    }
}
