Todaymade\Daux\Daux::getGenerator PHP Метод

getGenerator() публичный Метод

public getGenerator ( ) : Todaymade\Daux\Format\Base\Generator
Результат Todaymade\Daux\Format\Base\Generator
    public function getGenerator()
    {
        if ($this->generator) {
            return $this->generator;
        }
        $generators = $this->getGenerators();
        $format = $this->getParams()->getFormat();
        if (!array_key_exists($format, $generators)) {
            throw new \RuntimeException("The format '{$format}' doesn't exist, did you forget to set your processor ?");
        }
        $class = $generators[$format];
        if (!class_exists($class)) {
            throw new \RuntimeException("Class '{$class}' not found. We cannot use it as a Generator");
        }
        $interface = 'Todaymade\\Daux\\Format\\Base\\Generator';
        if (!in_array('Todaymade\\Daux\\Format\\Base\\Generator', class_implements($class))) {
            throw new \RuntimeException("The class '{$class}' does not implement the '{$interface}' interface");
        }
        return $this->generator = new $class($this);
    }