Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/**
4
 * This file is part of the Carbon package.
5
 *
6
 * (c) Brian Nesbitt <brian@nesbot.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Carbon\Cli;
13
 
14
class Invoker
15
{
16
    public const CLI_CLASS_NAME = 'Carbon\\Cli';
17
 
18
    protected function runWithCli(string $className, array $parameters): bool
19
    {
20
        $cli = new $className();
21
 
22
        return $cli(...$parameters);
23
    }
24
 
25
    public function __invoke(...$parameters): bool
26
    {
27
        if (class_exists(self::CLI_CLASS_NAME)) {
28
            return $this->runWithCli(self::CLI_CLASS_NAME, $parameters);
29
        }
30
 
31
        $function = (($parameters[1] ?? '') === 'install' ? ($parameters[2] ?? null) : null) ?: 'shell_exec';
32
        $function('composer require carbon-cli/carbon-cli --no-interaction');
33
 
34
        echo 'Installation succeeded.';
35
 
36
        return true;
37
    }
38
}