Completed
Pull Request — master (#10)
by Tomáš
31:42
created

Application::runCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\MultiCodingStandard\Application;
9
10
use Symplify\MultiCodingStandard\Application\Command\RunApplicationCommand;
11
use Symplify\MultiCodingStandard\PhpCsFixer\Application\Application as PhpCsFixerApplication;
12
use Symplify\MultiCodingStandard\PhpCsFixer\Application\Command\RunApplicationCommand as PhpCsFixerRunApplicationCommand;
13
use Symplify\PHP7_CodeSniffer\Application\Application as Php7CodeSnifferApplication;
14
use Symplify\PHP7_CodeSniffer\Application\Command\RunApplicationCommand as Php7CodeSnifferRunApplicationCommand;
15
16
final class Application
17
{
18
    /**
19
     * @var Php7CodeSnifferApplication
20
     */
21
    private $php7CodeSnifferApplication;
22
23
    /**
24
     * @var PhpCsFixerApplication
25
     */
26
    private $phpCsFixerApplication;
27
28
    public function __construct(
29
        Php7CodeSnifferApplication $php7CodeSnifferApplication,
30
        PhpCsFixerApplication $phpCsFixerApplication
31
    ) {
32
        $this->php7CodeSnifferApplication = $php7CodeSnifferApplication;
33
        $this->phpCsFixerApplication = $phpCsFixerApplication;
34
    }
35
36
    public function runCommand(RunApplicationCommand $command)
37
    {
38
        $this->php7CodeSnifferApplication->runCommand(
39
            $this->createPhp7CodeSnifferRunApplicationCommand($command)
40
        );
41
42
        $this->phpCsFixerApplication->runCommand(
43
            $this->createPhpCsFixerRunApplicationCommand($command)
44
        );
45
    }
46
47 View Code Duplication
    private function createPhp7CodeSnifferRunApplicationCommand(RunApplicationCommand $command) : Php7CodeSnifferRunApplicationCommand
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        return new Php7CodeSnifferRunApplicationCommand(
50
            $command->getSource(),
51
            $command->getJsonConfiguration()['standards'] ?? [],
52
            $command->getJsonConfiguration()['sniffs'] ?? [],
53
            $command->getJsonConfiguration()['exclude-sniffs'] ?? [],
54
            $command->isFixer()
55
        );
56
    }
57
58 View Code Duplication
    private function createPhpCsFixerRunApplicationCommand(RunApplicationCommand $command) : PhpCsFixerRunApplicationCommand
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        return new PhpCsFixerRunApplicationCommand(
61
            $command->getSource(),
62
            $command->getJsonConfiguration()['fixer-levels'] ?? [],
63
            $command->getJsonConfiguration()['fixers'] ?? [],
64
            $command->getJsonConfiguration()['exclude-fixers'] ?? [],
65
            $command->isFixer()
66
        );
67
    }
68
}
69