Skip to content
Snippets Groups Projects
Facet.php 792 B
Newer Older
Pavel's avatar
Pavel committed
<?php

namespace IQDEV\ElasticSearch\Facet;

Nikita Chernykh's avatar
Nikita Chernykh committed
use IQDEV\ElasticSearch\Facet\Item\FacetItemCollection;
use IQDEV\ElasticSearch\Facet\Type\FacetType;
Pavel's avatar
Pavel committed

Nikita Chernykh's avatar
Nikita Chernykh committed
class Facet implements Facetable
Pavel's avatar
Pavel committed
{
Nikita Chernykh's avatar
Nikita Chernykh committed
    public FacetItemCollection $products;

    protected FacetType $type;

    protected string $code;

    public function __construct(FacetType $type, string $code)
    {
        $this->type = $type;
        $this->code = $code;
        $this->products = new FacetItemCollection();
    }

    public function getType(): FacetType
    {
        return $this->type;
    }

    public function getCode(): string
    {
        return $this->code;
    }

    public function es(): array
    {
        return [
            'facet_code' => $this->code,
            'facet_value' => $this->type,
        ];
    }
Pavel's avatar
Pavel committed
}