<?php

namespace CouponsPlus\App\Data\Store;

use CouponsPlus\App\Data\Store\Abilities\Storable;

class StorerComposite implements Storable
{
    protected array $storers;

    public function __construct(array $storers)
    {
        $this->storers = $storers;
    }

    public function canBeStored(): bool
    {
        /**
         * Web only need one storer to be able to store
         */
        foreach ($this->storers as $storer) {
            if ($storer->canBeStored()) {
                return true;
            }
        }
        return false;
    }

    public function store(): void
    {
        foreach ($this->storers as $storer) {
            $storer->store();
        }
    }
}