<?php

declare(strict_types=1);

namespace apexl\Io\modules\tabulator\TabulatorActions;

use apexl\Io\modules\tabulator\Interfaces\TabulatorAction;
use apexl\Utils\Class\ClassBasename;
use JsonSerializable;
use Stringy\Stringy;

readonly class AbstractTabulatorAction implements TabulatorAction, JsonSerializable
{
    public function jsonSerialize(): array
    {
        return [
            'name' => $this->getName(),
            'params' => $this->getParameters()
        ];
    }

    public function getName(): string
    {
        return new Stringy(ClassBasename::classBasename($this::class))->dasherize()->toString();
    }

    public function getParameters(): array
    {
        return get_object_vars($this);
    }
}