Completed
Branch feature/scrutinizer (5874ea)
by X
03:07
created

IntegerParserTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 52
loc 52
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
B provideInvalidData() 35 35 1
A testParseFailure() 6 6 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
namespace xKerman\Restricted\Test;
4
5
use PHPUnit\Framework\TestCase;
6
7
use xKerman\Restricted\IntegerParser;
8
use xKerman\Restricted\Source;
9
10 View Code Duplication
class IntegerParserTest extends TestCase
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...
11
{
12
    public function provideInvalidData()
13
    {
14
        return [
15
            'empty string' => [
16
                'input' => '',
17
            ],
18
            'not integer' => [
19
                'input' => 'N;',
20
            ],
21
            'missing tag' => [
22
                'input' => ':0;',
23
            ],
24
            'missing value' => [
25
                'input' => 'i:;',
26
            ],
27
            'missing semicolon' => [
28
                'input' => 'i:0',
29
            ],
30
            'sign only' => [
31
                'input' => 'i:+;',
32
            ],
33
            'multiple sign' => [
34
                'input' => 'i:++6;',
35
            ],
36
            'float value' => [
37
                'input' => 'i:1.0;',
38
            ],
39
            'hex value' => [
40
                'input' => 'i:0x50;',
41
            ],
42
            'binary value' => [
43
                'input' => 'i:0b111;',
44
            ],
45
        ];
46
    }
47
48
    /**
49
     * @covers \xKerman\Restricted\IntegerParser
50
     * @covers \xKerman\Restricted\NumberLiteralParser
51
     * @covers \xKerman\Restricted\NumberStringParser
52
     * @dataProvider provideInvalidData
53
     * @expectedException \xKerman\Restricted\UnserializeFailedException
54
     */
55
    public function testParseFailure($input)
56
    {
57
        $source = new Source($input);
58
        $parser = new IntegerParser();
59
        $parser->parse($source);
60
    }
61
}
62