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

Application   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 37.74 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 20
loc 53
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 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\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