Completed
Push — master ( 3d7536...3ced6b )
by Marcin
02:56
created

PnaTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 60 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testPnaValidShort() 9 9 1
A testPnaValidLong() 9 9 1
A testPnaInvalid() 0 4 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
 * Validator
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For the full copyright and license information, please view source file
10
 * that is bundled with this package in the file LICENSE
11
 *
12
 * @author Marcin Pudełek <[email protected]>
13
 */
14
15
namespace mrcnpdlk\Validator;
16
17
use mrcnpdlk\Validator\Types\Pna;
18
19
class PnaTest extends TestCase
20
{
21 View Code Duplication
    public function testPnaValidShort()
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...
22
    {
23
        $defNr = '90019';
24
        $this->assertTrue(Pna::isValid($defNr, false));
25
        $res   = new Pna($defNr);
26
        $this->assertEquals('90019', $res->get());
27
        $this->assertEquals('90019', $res->getShort());
28
        $this->assertEquals('90-019', $res->getLong());
29
    }
30 View Code Duplication
    public function testPnaValidLong()
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...
31
    {
32
        $defNr = '90-019';
33
        $this->assertTrue(Pna::isValid($defNr, false));
34
        $res   = new Pna($defNr);
35
        $this->assertEquals('90019', $res->get());
36
        $this->assertEquals('90019', $res->getShort());
37
        $this->assertEquals('90-019', $res->getLong());
38
    }
39
40
    /**
41
     * @expectedException \mrcnpdlk\Validator\Exception
42
     */
43
    public function testPnaInvalid()
44
    {
45
        Pna::isValid('1-2345', true);
46
    }
47
48
}
49