1
<?php
2

3
namespace Carbon\Cli;
4

5
class Invoker
6
{
7
    const CLI_CLASS_NAME = 'Carbon\\Cli';
8

9 1
    protected function runWithCli(string $className, array $parameters): bool
10
    {
11 1
        $cli = new $className();
12

13 1
        return $cli(...$parameters);
14
    }
15

16 1
    public function __invoke(...$parameters): bool
17
    {
18 1
        if (class_exists(self::CLI_CLASS_NAME)) {
19 1
            return $this->runWithCli(self::CLI_CLASS_NAME, $parameters);
20
        }
21

22 1
        $function = (($parameters[1] ?? '') === 'install' ? ($parameters[2] ?? null) : null) ?: 'shell_exec';
23 1
        $function('composer require carbon-cli/carbon-cli --no-interaction');
24

25 1
        echo 'Installation succeeded.';
26

27 1
        return true;
28
    }
29
}

Read our documentation on viewing source code .

Loading