Completed
Push — master ( 26e69a...ab0b77 )
by Robin
03:27
created

ParseTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 20.83 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testParseStatementBank() 0 6 1
A testHasTheRightAmountOfTransactions() 0 10 2
A testParsesAllFoundStatements() 10 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 Kingsquare\Parser\Banking\Mt940\Engine\Spk;
4
5
use Kingsquare\Parser\Banking\Mt940\Engine\Spk;
6
7
/**
8
 *
9
 */
10
class ParseTest extends \PHPUnit_Framework_TestCase
11
{
12
    /**
13
     * @var Spk
14
     */
15
    private $engine = null;
16
17
    protected function setUp()
18
    {
19
        $this->engine = new Spk();
20
        $this->engine->loadString(file_get_contents(__DIR__.'/sample'));
21
    }
22
23
    /**
24
     *
25
     */
26
    public function testParseStatementBank()
27
    {
28
        $method = new \ReflectionMethod($this->engine, 'parseStatementBank');
29
        $method->setAccessible(true);
30
        $this->assertEquals('Spk', $method->invoke($this->engine));
31
    }
32
33
    /**
34
     *
35
     */
36
    public function testHasTheRightAmountOfTransactions()
37
    {
38
        $statements = $this->engine->parse();
39
        $this->assertSame(4, count($statements));
40
        $tranactions = [];
41
        foreach ($statements as $statement) {
42
            $tranactions = array_merge($tranactions, $statement->getTransactions());
43
        }
44
        $this->assertSame(10, count($tranactions));
45
    }
46
47 View Code Duplication
    public function testParsesAllFoundStatements()
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...
48
    {
49
        $statements = $this->engine->parse();
50
        $first = $statements[0];
51
        $last = end($statements);
52
        $this->assertEquals('17-02-2010', $first->getStartTimestamp('d-m-Y'));
53
        $this->assertEquals('17-02-2010', $first->getEndTimestamp('d-m-Y'));
54
        $this->assertEquals('18-02-2010', $last->getStartTimestamp('d-m-Y'));
55
        $this->assertEquals('18-02-2010', $last->getEndTimestamp('d-m-Y'));
56
    }
57
}
58