Rocketeer\Services\Tasks\TasksBuilder::buildStrategy PHP Метод

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

Build a strategy.
public buildStrategy ( string $strategy, string | null $concrete = null ) : Rocketeer\Abstracts\Strategies\AbstractStrategy | false
$strategy string
$concrete string | null
Результат Rocketeer\Abstracts\Strategies\AbstractStrategy | false
    public function buildStrategy($strategy, $concrete = null)
    {
        // If we passed a concrete implementation
        // build it, otherwise get the bound one
        $handle = strtolower($strategy);
        if ($concrete) {
            $path = 'Rocketeer\\Strategies\\' . ucfirst($strategy) . '\\%sStrategy';
            $class = sprintf($path, $concrete);
            $concrete = $this->findQualifiedName($concrete, [$path]);
            if (!$concrete) {
                throw new RuntimeException(sprintf('Class "%s" for strategy "%s" not found', $class, $strategy));
            }
            return new $concrete($this->app);
        }
        if (!isset($this->app['rocketeer.strategies.' . $handle])) {
            return false;
        }
        return $this->app['rocketeer.strategies.' . $handle];
    }