<?php

namespace GriffinForms\Includes\CommandPalette;

class SearchResultItem
{
    public string $result_id;
    public string $provider_id;
    public string $label;
    public string $description;
    public string $icon;
    public string $action_type;
    public array  $action_payload;
    public int    $score;

    public function __construct(
        string $result_id,
        string $provider_id,
        string $label,
        string $action_type,
        array  $action_payload,
        string $description = '',
        string $icon = '',
        int    $score = 0
    ) {
        $this->result_id      = $result_id;
        $this->provider_id    = $provider_id;
        $this->label          = $label;
        $this->description    = $description;
        $this->icon           = $icon;
        $this->action_type    = $action_type;
        $this->action_payload = $action_payload;
        $this->score          = $score;
    }

    public function toArray(): array
    {
        return [
            'result_id'      => $this->result_id,
            'provider_id'    => $this->provider_id,
            'label'          => $this->label,
            'description'    => $this->description,
            'icon'           => $this->icon,
            'action_type'    => $this->action_type,
            'action_payload' => $this->action_payload,
            'score'          => $this->score,
        ];
    }
}
