GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6c9463...1c02a4 )
by Cees-Jan
08:47
created

Installer::install()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
1
<?php declare(strict_types = 1);
2
3
namespace ApiClients\Tools\Installer;
4
5
use Composer\Composer;
6
use Composer\Factory;
7
use InvalidArgumentException;
8
use PackageVersions\Versions;
9
use Symfony\Component\Console\Application;
10
use Symfony\Component\Console\Input\ArgvInput;
11
use Symfony\Component\Console\Output\ConsoleOutput;
12
use Symfony\Component\Yaml\Yaml;
13
use Throwable;
14
15
final class Installer
16
{
17
    const TITLE = 'PHP API Clients skeleton installer';
18
19
    public static function postCreateProject()
20
    {
21
        try {
22
            $path = str_replace(
23
                'composer.json',
24
                'installer.yml',
25
                Factory::getComposerFile()
26
            );
27
28
            if (!file_exists($path)) {
29
                throw new InvalidArgumentException('Missing installer configuration file');
30
            }
31
32
            static::install($path);
0 ignored issues
show
Comprehensibility introduced by
Since ApiClients\Tools\Installer\Installer is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
33
        } catch (Throwable $throwable) {
34
            echo get_class($throwable), ' thrown with message: ', $throwable->getMessage(), PHP_EOL;
35
            echo $throwable->getTraceAsString(), PHP_EOL;
36
            exit(1);
0 ignored issues
show
Coding Style Compatibility introduced by
The method postCreateProject() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
37
        }
38
    }
39
40
    private static function install(string $fileName)
41
    {
42
        $yaml = Yaml::parse(
43
            file_get_contents(
44
                $fileName
45
            )
46
        );
47
        $app = new Application(
48
            self::TITLE,
49
            Versions::getVersion('api-clients/installer')
50
        );
51
        $app->add((new Install(Install::COMMAND))->setYaml($yaml));
52
        $app->find(Install::COMMAND)->run(new ArgvInput([]), new ConsoleOutput());
53
    }
54
}
55