Completed
Pull Request — master (#10)
by Tomáš
03:33
created

Application   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 36.36 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 6
dl 20
loc 55
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A runCommand() 0 10 1
A createPhp7CodeSnifferRunApplicationCommand() 10 10 1
A createPhpCsFixerRunApplicationCommand() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\CodeSniffer\Legacy\Version2ClassAliases;
12
use Symplify\MultiCodingStandard\PhpCsFixer\Application\Application as PhpCsFixerApplication;
13
use Symplify\MultiCodingStandard\PhpCsFixer\Application\Command\RunApplicationCommand as PhpCsFixerRunApplicationCommand;
14
use Symplify\PHP7_CodeSniffer\Application\Application as Php7CodeSnifferApplication;
15
use Symplify\PHP7_CodeSniffer\Application\Command\RunApplicationCommand as Php7CodeSnifferRunApplicationCommand;
16
17
final class Application
18
{
19
    /**
20
     * @var Php7CodeSnifferApplication
21
     */
22
    private $php7CodeSnifferApplication;
23
24
    /**
25
     * @var PhpCsFixerApplication
26
     */
27
    private $phpCsFixerApplication;
28
29
    public function __construct(
30
        Php7CodeSnifferApplication $php7CodeSnifferApplication,
31
        PhpCsFixerApplication $phpCsFixerApplication
32
    ) {
33
        $this->php7CodeSnifferApplication = $php7CodeSnifferApplication;
34
        $this->phpCsFixerApplication = $phpCsFixerApplication;
35
36
        Version2ClassAliases::register();
37
    }
38
39
    public function runCommand(RunApplicationCommand $command)
40
    {
41
        $this->php7CodeSnifferApplication->runCommand(
42
            $this->createPhp7CodeSnifferRunApplicationCommand($command)
43
        );
44
45
        $this->phpCsFixerApplication->runCommand(
46
            $this->createPhpCsFixerRunApplicationCommand($command)
47
        );
48
    }
49
50 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...
51
    {
52
        return new Php7CodeSnifferRunApplicationCommand(
53
            $command->getSource(),
54
            $command->getJsonConfiguration()['standards'] ?? [],
55
            $command->getJsonConfiguration()['sniffs'] ?? [],
56
            $command->getJsonConfiguration()['exclude-sniffs'] ?? [],
57
            $command->isFixer()
58
        );
59
    }
60
61 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...
62
    {
63
        return new PhpCsFixerRunApplicationCommand(
64
            $command->getSource(),
65
            $command->getJsonConfiguration()['fixer-levels'] ?? [],
66
            $command->getJsonConfiguration()['fixers'] ?? [],
67
            $command->getJsonConfiguration()['exclude-fixers'] ?? [],
68
            $command->isFixer()
69
        );
70
    }
71
}
72