Passed
Push — master ( 4ebeec...f195ba )
by Gerrit
02:48
created

CorrectOrderInVarDocCommentFixerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 102
Duplicated Lines 59.8 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 61
loc 102
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testFix() 0 4 1
B provideFixCases() 61 61 1
A shouldHaveAFixerDefinition() 0 17 1
A createFixer() 0 4 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 PHP CS Fixer.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *     Dariusz Rumiński <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Addiks\MorePhpCsFixers\Tests\Unit\DocComment;
14
15
use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
16
use PhpCsFixer\FixerDefinition\FixerDefinition;
17
use PhpCsFixer\FixerDefinition\CodeSample;
18
use Addiks\MorePhpCsFixers\DocComment\CorrectOrderInVarDocCommentFixer;
19
20
/**
21
 * @internal
22
 */
23
final class CorrectOrderInVarDocCommentFixerTest extends AbstractFixerTestCase
24
{
25
    /**
26
     * @param string      $expected
27
     * @param null|string $input
28
     *
29
     * @dataProvider provideFixCases
30
     */
31
    public function testFix($expected, $input = null)
32
    {
33
        $this->doTest($expected, $input);
34
    }
35
36 View Code Duplication
    public function provideFixCases()
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...
37
    {
38
        return [
39
            [
40
                '<?php
41
/** @var string $foo */
42
/** @var int $foo */
43
/** @var Foo $foo */
44
/** @var Foo\Bar $foo */
45
/** @var \Foo $foo */
46
/**
47
 * @var Foo $foo
48
 */
49
',
50
            ],
51
            [
52
                '<?php
53
/** @var string $foo */
54
/** @var int $foo */
55
/** @var Foo $foo */
56
/** @var Foo\Bar $foo */
57
/** @var \Foo $foo */
58
/**
59
 * @var Foo $foo
60
 */
61
',
62
                '<?php
63
/** @var $foo string */
64
/** @var $foo int */
65
/** @var $foo Foo */
66
/** @var $foo Foo\Bar */
67
/** @var $foo \Foo */
68
/**
69
 * @var $foo Foo
70
 */
71
',
72
            ],
73
            [
74
                '<?php
75
    /** @var string $foo */
76
    /** @var int $foo */
77
    /** @var Foo $foo */
78
    /** @var Foo\Bar $foo */
79
    /** @var \Foo $foo */
80
    /**
81
     * @var Foo $foo
82
     */
83
',
84
                '<?php
85
    /** @var $foo string */
86
    /** @var $foo int */
87
    /** @var $foo Foo */
88
    /** @var $foo Foo\Bar */
89
    /** @var $foo \Foo */
90
    /**
91
     * @var $foo Foo
92
     */
93
',
94
            ],
95
        ];
96
    }
97
98
    /**
99
     * @test
100
     */
101
    public function shouldHaveAFixerDefinition()
102
    {
103
        $this->assertEquals(
104
            new FixerDefinition(
105
                'Corrects the order of variable and typedeclaration in a @var doccomment.',
106
                [
107
                    new CodeSample(
108
                        '<?php
109
110
/** @var string $foo */
111
'
112
                    ),
113
                ]
114
            ),
115
            $this->createFixer()->getDefinition()
116
        );
117
    }
118
119
    protected function createFixer()
120
    {
121
        return new CorrectOrderInVarDocCommentFixer();
122
    }
123
124
}
125