Failed Conditions
Push — phpcs-3-upgrade ( d91341 )
by Alexander
02:06
created

ArrayUnitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorList() 0 14 1
A getWarningList() 0 17 1
1
<?php
2
/**
3
 * CodingStandard_Tests_Array_ArrayUnitTest.
4
 *
5
 * PHP version 5
6
 *
7
 * @category PHP
8
 * @package  PHP_CodeSniffer
9
 * @author   Alexander Obuhovich <[email protected]>
10
 * @license  https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause
11
 * @link     https://github.com/aik099/CodingStandard
12
 */
13
14
namespace CodingStandard\Tests\Arrays;
15
16
use TestSuite\AbstractSniffUnitTest;
17
18
/**
19
 * Unit test class for the Array sniff.
20
 *
21
 * @category PHP
22
 * @package  PHP_CodeSniffer
23
 * @author   Alexander Obuhovich <[email protected]>
24
 * @license  https://github.com/aik099/CodingStandard/blob/master/LICENSE BSD 3-Clause
25
 * @link     https://github.com/aik099/CodingStandard
26
 */
27
class ArrayUnitTest extends AbstractSniffUnitTest
28
{
29
30
31
    /**
32
     * Returns the lines where errors should occur.
33
     *
34
     * The key of the array should represent the line number and the value
35
     * should represent the number of errors that should occur on that line.
36
     *
37
     * @param string $testFile Name of the file with test data.
38
     *
39
     * @return array(int => int)
40
     */
41
    public function getErrorList($testFile)
42
    {
43
        return array(
44
                // Space after "array" keyword.
45
                2  => 1,
46
                // Malformed empty array.
47
                3  => 1,
48
                5  => 1,
49
                // Space after opening array brace.
50
                10 => 1,
51
                // Space before closing array brace.
52
                11 => 1,
53
               );
54
    }//end getErrorList()
55
56
57
    /**
58
     * Returns the lines where warnings should occur.
59
     *
60
     * The key of the array should represent the line number and the value
61
     * should represent the number of warnings that should occur on that line.
62
     *
63
     * @param string $testFile Name of the file with test data.
64
     *
65
     * @return array(int => int)
66
     */
67
    public function getWarningList($testFile)
68
    {
69
        return array(
70
                // No comma after multi-line array last element.
71
                7 => 1,
72
                // Comma after last element of single-line array.
73
                9 => 1,
74
                // Space after last element (nested multi-line array).
75
                14 => 1,
76
                // Space after last element (multi-line array).
77
                18 => 1,
78
                // Space after last element (nested multi-line array).
79
                19 => 1,
80
                // No comma after last element followed by comment on next line.
81
                22 => 1,
82
               );
83
    }//end getWarningList()
84
}//end class
85