<?php

declare(strict_types=1);

namespace Builder\Core\Foundation\Definition;

final class JsModule
{
    public string $key = '';

    public string $entry = 'resources/js/module.ts';

    public ?string $label = null;

    public ?string $publicPath = null;

    public ?string $version = null;

    public ?string $author = null;

    public ?string $authorUrl = null;

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

    public function setKey(string $key): self
    {
        $this->key = $key;

        return $this;
    }

    public function setEntry(string $entry = 'resources/js/module.ts'): self
    {
        $this->entry = $entry;

        return $this;
    }

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

    public function setLabel(?string $label): self
    {
        $this->label = $label;

        return $this;
    }

    public function getLabel(): ?string
    {
        return $this->label;
    }

    public function setPublicPath(string $path): self
    {
        $this->publicPath = $path;

        return $this;
    }

    public function getPublicPath(): ?string
    {
        return $this->publicPath;
    }

    public function setVersion(?string $version): self
    {
        $this->version = $version;

        return $this;
    }

    public function getVersion(): ?string
    {
        return $this->version;
    }

    public function setAuthor(?string $author): self
    {
        $this->author = $author;

        return $this;
    }

    public function getAuthor(): ?string
    {
        return $this->author;
    }

    public function setAuthorUrl(?string $authorUrl): self
    {
        $this->authorUrl = $authorUrl;

        return $this;
    }

    public function getAuthorUrl(): ?string
    {
        return $this->authorUrl;
    }

    /** @return array<string, mixed> */
    public function toArray(): array
    {
        return [
            'key' => $this->key,
            'entry' => $this->entry,
            'label' => $this->label,
            'version' => $this->version,
            'author' => $this->author,
            'author_url' => $this->authorUrl,
        ];
    }

    public static function make(): self
    {
        return new JsModule;
    }
}
