<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ProductFields\Value;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ProductFields\ProductFieldArrayValue;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ProductFields\ProductFieldValue;
use WC_Product;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Integration\GpsrIntegration;
class ResponsiblePersonProductFieldValue implements ProductFieldValue, ProductFieldArrayValue
{
    public const KEY = 'responsible_person';
    private ?array $value = null;
    private WC_Product $product;
    public function __construct(WC_Product $product)
    {
        $this->product = $product;
    }
    public static function get_key(): string
    {
        return self::KEY;
    }
    public static function get_name(): string
    {
        return esc_attr__('Responsible persons', 'dropshipping-export-free');
    }
    public function has_array_value(): bool
    {
        return \is_array($this->get_array_value());
    }
    public function get_array_value(): ?array
    {
        if ($this->value !== null) {
            return $this->value;
        }
        $this->value = GpsrIntegration::get_responsible_person_data($this->product);
        return $this->value;
    }
}
