AfmTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 19.23 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testValidAfms() 0 10 1
A testInvalidAfms() 10 10 1
A validAfmProvider() 0 13 1
A invalidAfmProvider() 0 7 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 AfmTest extends TestCase
9
{
10
    /**
11
     * @dataProvider validAfmProvider
12
     */
13
    public function testValidAfms($afm)
14
    {
15
        $validator = Validation::createValidator();
16
17
        $violations = $validator->validate($afm, [
18
            new Afm(),
19
        ]);
20
21
        $this->assertEmpty($violations);
22
    }
23
24
    /**
25
     * @dataProvider invalidAfmProvider
26
     */
27 View Code Duplication
    public function testInvalidAfms($afm)
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($afm, [
32
            new Afm(),
33
        ]);
34
35
        $this->assertNotEmpty($violations);
36
    }
37
38
    public function validAfmProvider()
39
    {
40
        return [
41
            [''],
42
            [null],
43
            ['094075243'],
44
            ['094079531'],
45
            ['997364193'],
46
            ['800785347'],
47
            ['094066928'],
48
            ['084256593'],
49
        ];
50
    }
51
52
    public function invalidAfmProvider()
53
    {
54
        return [
55
            ['026051931'],
56
            ['aaaa'],
57
        ];
58
    }
59
}
60