Passed
Push — master ( 7fc1c6...790207 )
by Adelar
04:53
created

OfxParseTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 54.79 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 6
c 5
b 0
f 0
lcom 1
cbo 3
dl 40
loc 73
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A wrongXmlFormat() 0 5 1
A itau() 8 8 1
A santander() 8 8 1
A caixa() 8 8 1
A faturaCC() 8 8 1
A itauIso() 8 8 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
namespace Adelarcubs\OFXParser;
3
4
use PHPUnit_Framework_TestCase;
5
use SimpleXMLElement;
6
use Adelarcubs\OFXParser\Ofx;
7
use Adelarcubs\OFXParser\OfxParser;
8
use Adelarcubs\OFXParser\OfxMovement;
9
10
/**
11
 *
12
 * @author Adelar Tiemann Junior <[email protected]>
13
 */
14
class OfxParseTest extends PHPUnit_Framework_TestCase
15
{
16
17
    /**
18
     * @test
19
     * @expectedException Exception
20
     */
21
    public function wrongXmlFormat()
22
    {
23
        $ofx = OfxParser::loadOfx('<OFX><root></rot></OFX>');
24
        $this->assertNull($ofx);
25
    }
26
27
    /**
28
     * @test
29
     */
30 View Code Duplication
    public function itau()
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
        $ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/extrato_itau.ofx');
33
        $this->assertInstanceOf(Ofx::class, $ofx);
34
        $this->assertInternalType('array', $ofx->jsonSerialize());
35
36
        $this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements());
37
    }
38
39
    /**
40
     * @test
41
     */
42 View Code Duplication
    public function santander()
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...
43
    {
44
        $ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/extrato_santander.ofx');
45
        $this->assertInstanceOf(Ofx::class, $ofx);
46
        $this->assertInternalType('array', $ofx->jsonSerialize());
47
48
        $this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements());
49
    }
50
51
    /**
52
     * @test
53
     */
54 View Code Duplication
    public function caixa()
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...
55
    {
56
        $ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/extrato_caixa.ofx');
57
        $this->assertInstanceOf(Ofx::class, $ofx);
58
        $this->assertInternalType('array', $ofx->jsonSerialize());
59
60
        $this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements());
61
    }
62
63
    /**
64
     * @test
65
     */
66 View Code Duplication
    public function faturaCC()
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...
67
    {
68
        $ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/fatura_cc_1.ofx');
69
        $this->assertInstanceOf(Ofx::class, $ofx);
70
        $this->assertInternalType('array', $ofx->jsonSerialize());
71
72
        $this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements());
73
    }
74
75
    /**
76
     * @test
77
     */
78 View Code Duplication
    public function itauIso()
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...
79
    {
80
        $ofx = OfxParser::loadOfx(__DIR__ . '/fixtures/extrato_itau_iso.ofx');
81
        $this->assertInstanceOf(Ofx::class, $ofx);
82
        $this->assertInternalType('array', $ofx->jsonSerialize());
83
84
        $this->assertContainsOnlyInstancesOf(OfxMovement::class, $ofx->getMovements());
85
    }
86
}
87