<?php

namespace RTMCustomMails\ConditionProcessor;

use RTMCustomMails\SupportedObjectTypes;
use RTMMailComposer\ConditionProcessor\ConditionFunctionInterface;
use WC_Abstract_Order;

class OrderIsGuestCondition implements ConditionFunctionInterface
{

    public function __construct()
    {
    }

    public function getName(): string
    {
        return 'order_is_guest';
    }

    public function getParameters(): array
    {
        return [];
    }

    public function evaluate(array $context): bool
    {
        /** @var WC_Abstract_Order|null $order */
        $order = $context['order'] ?? null;
        if ($order) {
            return !$order->get_customer_id();
        }
        return false;
    }

    public function getObjectType(): string
    {
        return SupportedObjectTypes::ORDER->value;
    }
}