Comos\Qpm\Supervision\Config::_initFactory PHP Method

_initFactory() private method

private _initFactory ( $config )
    private function _initFactory($config)
    {
        if (isset($config['factory'])) {
            if (!\is_callable($config['factory'])) {
                throw new \InvalidArgumentException('factory must be callable');
            }
            $this->_factory = $config['factory'];
            return;
        }
        if (isset($config['worker'])) {
            $worker = $config['worker'];
            if (is_callable($worker)) {
                $this->_factory = function () use($worker) {
                    return $worker;
                };
                return;
            }
            if (is_subclass_of($worker, '\\Comos\\Qpm\\Process\\Runnable')) {
                $this->_factory = function () use($worker) {
                    $workerInst = new $worker();
                    return array($workerInst, 'run');
                };
                return;
            }
            throw new \InvalidArgumentException('worker must be an instance of Comos\\Qpm\\Process\\Runnable or callable');
        }
        throw new \InvalidArgumentException('a factory or worker is required.');
    }