<?php

namespace CouponsPlus\App\Coupon\Tree\ItemSetsToDiscount;

use CouponsPlus\Original\Collections\Collection;
use CouponsPlus\App\Coupon\Tree\ItemSetsToDiscount\Actions\CartAction;

class CartActions
{

    protected Collection $actions;

    public function __construct(array $actions)
    {
        /** @noinspection PhpUnhandledExceptionInspection */
        $this->actions = new Collection($actions);
    }

    public function has(string $action) : bool
    {
        /** @noinspection PhpUnhandledExceptionInspection */
        return $this->actions->contain(function (CartAction $cartAction) use ($action): bool {
            return $cartAction->getID() === $action;
        });
    }
}