Launcher::main()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Matks\PHPMakeUp;
4
5
use Matks\PHPMakeUp\File\FileManager;
6
use Matks\PHPMakeUp\LineAlignment\LineAligner;
7
use Matks\PHPMakeUp\UseSorting\UseSortingManager;
8
9
/**
10
 * PHPMakeUp Launcher
11
 *
12
 * This class setups the PHPMakeUp tool
13
 */
14
class Launcher
15
{
16
17
    /**
18
     * Main
19
     *
20
     * @param string $filepath
21
     */
22
    public static function main($filepath)
23
    {
24
        $launcher = new Launcher();
25
        $launcher->run((string) $filepath);
26
    }
27
28
    /**
29
     * Run
30
     *
31
     * @param string $filepath
32
     */
33
    public function run($filepath)
34
    {
35
        $phpCleaner = $this->setup();
36
        $phpCleaner->clean($filepath);
37
38
        die(0);
0 ignored issues
show
Coding Style Compatibility introduced by
The method run() 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...
39
    }
40
41
    /**
42
     * Construct PHPCleaner instance with its dependencies
43
     *
44
     * @return PHPCleaner
45
     */
46
    private function setup()
47
    {
48
        $fileManager       = new FileManager();
49
        $lineAligner       = new LineAligner($fileManager);
50
        $useSortingManager = new UseSortingManager($fileManager);
51
52
        $phpCleaner = new phpCleaner($lineAligner, $useSortingManager);
53
54
        return $phpCleaner;
55
    }
56
}
57