KadTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 18.52 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testValidKads() 0 10 1
A testInvalidKads() 10 10 1
A validKadProvider() 0 12 1
A invalidKadProvider() 0 10 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 SymfonyGreekValidation;
4
5
use PHPUnit\Framework\TestCase;
6
use Symfony\Component\Validator\Validation;
7
8
class KadTest extends TestCase
9
{
10
    /**
11
     * @dataProvider validKadProvider
12
     */
13
    public function testValidKads($kad)
14
    {
15
        $validator = Validation::createValidator();
16
17
        $violations = $validator->validate($kad, [
18
            new Kad(),
19
        ]);
20
21
        $this->assertEmpty($violations);
22
    }
23
24
    /**
25
     * @dataProvider invalidKadProvider
26
     */
27 View Code Duplication
    public function testInvalidKads($kad)
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...
28
    {
29
        $validator = Validation::createValidator();
30
31
        $violations = $validator->validate($kad, [
32
            new Kad(),
33
        ]);
34
35
        $this->assertNotEmpty($violations);
36
    }
37
38
    public function validKadProvider()
39
    {
40
        return [
41
            [''],
42
            [null],
43
            ['01.00.00.00'],
44
            ['63.11.13.00'],
45
            ['62.01.11.03'],
46
            ['61.10.52.01'],
47
            ['42.91.20.02'],
48
        ];
49
    }
50
51
    public function invalidKadProvider()
52
    {
53
        return [
54
            ['01000400500'],
55
            ['01.00.00.0a'],
56
            ['01.00.00.00.'],
57
            ['.01.00.00.00'],
58
            ['1.00.00.00'],
59
        ];
60
    }
61
}
62