Debian Codegraph @

lib/3rdParty/composer/nesbot/carbon/src/Carbon/Cli/Invoker.php

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