<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Fields;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Fields\Abstraction\WPPostsMetaField;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Fields\Abstraction\Field;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Fields\Abstraction\AllowedConditions;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Conditions\ContainsCondition;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Conditions\EqualCondition;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Integration\EanIntegration;
use WC_Product;
class EANField implements Field, WPPostsMetaField, AllowedConditions
{
    public static function get_allowed_conditions(): array
    {
        return [ContainsCondition::class, EqualCondition::class];
    }
    public static function get_name(): string
    {
        return 'ean';
    }
    public static function get_nice_name(): string
    {
        return __('Product EAN', 'dropshipping-export-free');
    }
    public static function get_meta_key(): string
    {
        return EanIntegration::META_KEY;
    }
    public function get_product_value(WC_Product $product)
    {
        $ean = EanIntegration::get_ean_field($product);
        return (\is_string($ean) && \strlen($ean)) >= 1 ? $ean : '';
    }
}
