<?php
declare(strict_types=1);

namespace App\Service\Rest\Operation;

use JetBrains\PhpStorm\Pure;

/**
 * A single delete operation (a DELETE request)
 */
class DeleteOperation extends BaseRestOperation
{
    /**
     * @param string $label A label for the operation
     * @param string $entityName The name of the entity to update. This will be used in the path of the request.
     * @param int $id
     * @param array<mixed> $initialData The data of the existing object, before the update
     * @param array<mixed> $options
     */
    #[Pure]
    public function __construct(
        protected string $label,
        protected string $entityName,
        protected int $id,
        protected array $initialData = [],
        protected array $options = []
    ) {
        parent::__construct(
            $label,
            'DELETE',
            $entityName . '/' . $id,
            [],
            [],
            $options
        );
    }

    /**
     * @return string
     */
    public function getEntityName(): string
    {
        return $this->entityName;
    }

    /**
     * @return array<mixed>|null
     */
    protected function getExpectedResult(): ?array {
        return null;
    }

    /**
     * Return an array of messages describing the change that this operation will bring
     *
     * @return list<string>
     */
    public function getChangeLog(): array
    {
        return [
            '[DELETE ' . $this->entityName . '/' . $this->id . ']'
        ];
    }
}
