<?php

namespace KupShop\AdminBundle\AdminRegister;

use KupShop\AdminBundle\Util\PrintCenter\PrintLabelsBase;

class ProductsPrintLabelsLocator
{
    private $printClasses = [];

    /**
     * ProductsPrintLabelsLocator constructor.
     *
     * @param PrintLabelsBase[] $printClasses
     */
    public function __construct(iterable $printClasses)
    {
        foreach ($printClasses as $class) {
            if (isset($class->isWarehouse) && $class->isWarehouse) {
                continue;
            }
            $this->printClasses[$class->getLabel()] = $class;
        }
    }

    /**
     * @return PrintLabelsBase[]
     */
    public function getPrintClasses()
    {
        return $this->printClasses;
    }

    /**
     * @return PrintLabelsBase|false
     */
    public function getPrintClass($type)
    {
        return $this->printClasses[$type] ?? false;
    }
}
