Passed
Push — master ( ddbdf0...1a517e )
by Théo
02:39
created

ComposerOrchestrator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
eloc 0
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the box project.
7
 *
8
 * (c) Kevin Herrera <[email protected]>
9
 *     Théo Fidry <[email protected]>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14
15
namespace KevinGH\Box\Composer;
16
17
use Composer\Console\Application as ComposerApplication;
18
use Symfony\Component\Console\Input\ArrayInput;
19
use Symfony\Component\Console\Output\NullOutput;
20
21
final class ComposerOrchestrator
22
{
23
    private function __construct()
24
    {
25
    }
26
27
    public static function dumpAutoload(): void
28
    {
29
        $composerApplication = new ComposerApplication();
30
        $composerApplication->doRun(new ArrayInput([]), new NullOutput());
31
32
        $composer = $composerApplication->getComposer(false);
33
34
        if (null === $composer) {
35
            return; // No autoload to dump
36
        }
37
38
        $installationManager = $composer->getInstallationManager();
39
        $localRepo = $composer->getRepositoryManager()->getLocalRepository();
40
        $package = $composer->getPackage();
41
        $config = $composer->getConfig();
42
43
        $generator = $composer->getAutoloadGenerator();
44
        $generator->setDevMode(false);
45
        $generator->setClassMapAuthoritative(true);
46
47
        $generator->dump($config, $localRepo, $package, $installationManager, 'composer', true);
48
    }
49
}
50