Passed
Pull Request — master (#1)
by Jitendra
01:24
created

FixerTest::theTests()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 89
Code Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 59
nc 1
nop 0
dl 0
loc 89
rs 8.8945
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Ahc\Test\Json;
4
5
use Ahc\Json\Fixer;
6
7
class FixerTest extends \PHPUnit\Framework\TestCase
8
{
9
    protected static $fixer;
10
11
    public static function setUpBeforeClass()
12
    {
13
        static::$fixer = new Fixer;
14
    }
15
16
    /** @dataProvider theTests */
17
    public function test($json, $expect, $msg = null)
18
    {
19
        $this->assertSame($expect, static::$fixer->fix($json), $msg);
20
    }
21
22
    public function theTests()
23
    {
24
        return [[
25
            'json'   => '',
26
            'expect' => '',
27
        ], [
28
            'json'   => '"',
29
            'expect' => '""',
30
        ], [
31
            'json'   => '"a"',
32
            'expect' => '"a"',
33
        ], [
34
            'json'   => 'true',
35
            'expect' => 'true',
36
        ], [
37
            'json'   => 'false',
38
            'expect' => 'false',
39
        ], [
40
            'json'   => 'null',
41
            'expect' => 'null',
42
        ], [
43
            'json'   => 'fal',
44
            'expect' => 'false',
45
        ], [
46
            'json'   => 't',
47
            'expect' => 'true',
48
        ], [
49
            'json'   => 'nu',
50
            'expect' => 'null',
51
        ], [
52
            'json'   => '{',
53
            'expect' => '{}',
54
        ], [
55
            'json'   => '[',
56
            'expect' => '[]',
57
        ], [
58
            'json'   => '[{',
59
            'expect' => '[{}]',
60
        ], [
61
            'json'   => '[1',
62
            'expect' => '[1]',
63
        ], [
64
            'json'   => '["',
65
            'expect' => '[""]',
66
        ], [
67
            'json'   => '[1,',
68
            'expect' => '[1]',
69
        ], [
70
            'json'   => '[1,{',
71
            'expect' => '[1,{}]',
72
        ], [
73
            'json'   => '["a',
74
            'expect' => '["a"]',
75
        ], [
76
            'json'   => '["b,',
77
            'expect' => '["b,"]',
78
        ], [
79
            'json'   => '["b",{"',
80
            'expect' => '["b",{"":null}]',
81
        ], [
82
            'json'   => '["b",{"a',
83
            'expect' => '["b",{"a":null}]',
84
        ], [
85
            'json'   => '["b",{"a":',
86
            'expect' => '["b",{"a":null}]',
87
        ], [
88
            'json'   => '["b",{"a":[t',
89
            'expect' => '["b",{"a":[true]}]',
90
        ], [
91
            'json'   => '{"a":2',
92
            'expect' => '{"a":2}',
93
        ], [
94
            'json'   => '{"',
95
            'expect' => '{"":null}',
96
        ], [
97
            'json'   => '{"a":1.2,',
98
            'expect' => '{"a":1.2}',
99
        ], [
100
            'json'   => '{"a":"',
101
            'expect' => '{"a":""}',
102
        ], [
103
            'json'   => '{"a":[',
104
            'expect' => '{"a":[]}',
105
        ], [
106
            'json'   => '{"a":"b","b":["',
107
            'expect' => '{"a":"b","b":[""]}',
108
        ], [
109
            'json'   => '{"a":"b","b":[t',
110
            'expect' => '{"a":"b","b":[true]}',
111
        ],
112
        ];
113
    }
114
}
115