Completed
Push — master ( 77f799...365b3d )
by Adelar
02:21
created

OfxTest::invalidFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Adelarcubs\OFXParser;
3
4
use PHPUnit_Framework_TestCase;
5
use SimpleXMLElement;
6
7
/**
8
 *
9
 * @author Adelar Tiemann Junior <[email protected]>
10
 */
11
class OfxTest extends PHPUnit_Framework_TestCase
12
{
13
14
    private $ofx;
15
16
    protected function setUp()
17
    {
18
        // $this->ofx = new Ofx(new SimpleXMLElement('fixtures/data.ofx'));
19
        $this->ofx = Ofx::loadFromFile(__DIR__ . '/fixtures/data.ofx');
0 ignored issues
show
Documentation introduced by
__DIR__ . '/fixtures/data.ofx' is of type string, but the function expects a object<Adelarcubs\OFXParser\unknown>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
20
    }
21
22
    /**
23
     * @test
24
     */
25
    public function constructorShouldConfigureAttributes()
26
    {
27
        $this->assertInstanceOf(Ofx::class, $this->ofx);
28
    }
29
    /**
30
     * @test
31
     * @expectedException InvalidArgumentException
32
     */
33
    public function invalidFile(){
34
        $ofx = Ofx::loadFromFile('Anywhere');
0 ignored issues
show
Documentation introduced by
'Anywhere' is of type string, but the function expects a object<Adelarcubs\OFXParser\unknown>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Unused Code introduced by
$ofx is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
35
    }
36
}
37