PropertyCommentUnitTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 54
loc 54
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorList() 21 21 3
A getWarningList() 5 5 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 the mo4-coding-standard (phpcs standard)
5
 *
6
 * PHP version 5
7
 *
8
 * @category PHP
9
 * @package  PHP_CodeSniffer-MO4
10
 * @author   Xaver Loppenstedt <[email protected]>
11
 * @license  http://spdx.org/licenses/MIT MIT License
12
 * @version  GIT: master
13
 * @link     https://github.com/Mayflower/mo4-coding-standard
14
 */
15
16
/**
17
 * Unit test class for the AlphabeticalUseStatements sniff.
18
 *
19
 * A sniff unit test checks a .inc file for expected violations of a single
20
 * coding standard. Expected errors and warnings are stored in this class.
21
 *
22
 * @category  PHP
23
 * @package   PHP_CodeSniffer-MO4
24
 * @author    Xaver Loppenstedt <[email protected]>
25
 * @copyright 2014 Xaver Loppenstedt, some rights reserved.
26
 * @license   http://spdx.org/licenses/MIT MIT License
27
 * @link      https://github.com/Mayflower/mo4-coding-standard
28
 */
29
namespace MO4\Tests\Commenting;
30
31
use PHP_CodeSniffer\Exceptions\RuntimeException;
32
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
33
34 View Code Duplication
class PropertyCommentUnitTest extends AbstractSniffUnitTest
0 ignored issues
show
Duplication introduced by
This class 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...
35
{
36
37
38
    /**
39
     * Returns the lines where errors should occur.
40
     *
41
     * The key of the array should represent the line number and the value
42
     * should represent the number of errors that should occur on that line.
43
     *
44
     * @param string $testFile test file
45
     *
46
     * @return array<int, int>
0 ignored issues
show
Documentation introduced by
The doc-type array<int, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
47
     * @throws RuntimeException
48
     */
49
    protected function getErrorList($testFile='')
50
    {
51
        switch ($testFile) {
52
        case 'PropertyCommentUnitTest.pass.inc':
53
            return array();
54
        case 'PropertyCommentUnitTest.fail.inc':
55
            return array(
56
                    7  => 1,
57
                    10 => 1,
58
                    17 => 1,
59
                    26 => 2,
60
                    29 => 1,
61
                    34 => 1,
62
                    37 => 1,
63
                    41 => 1,
64
                   );
65
        }
66
67
        throw new RuntimeException("Testfile {$testFile} in ".__DIR__." is not handled by ".__CLASS__);
68
69
    }//end getErrorList()
70
71
72
    /**
73
     * Returns the lines where warnings should occur.
74
     *
75
     * The key of the array should represent the line number and the value
76
     * should represent the number of warnings that should occur on that line.
77
     *
78
     * @return array<int, int>
0 ignored issues
show
Documentation introduced by
The doc-type array<int, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
79
     */
80
    protected function getWarningList()
81
    {
82
        return array();
83
84
    }//end getWarningList()
85
86
87
}//end class
88