GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ImageModelTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSettersAndGetters() 0 13 1
A testGetExceptionWithInvalidConstructorArgument() 0 5 1
1
<?php
2
namespace HtImgModuleTest\View\Model;
3
4
use HtImgModule\View\Model\ImageModel;
5
use Imagine\Gd\Imagine;
6
7
class ImageModelTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testSettersAndGetters()
10
    {
11
        $imageOutputOptions = ['quality' => 93];
12
        $model = new ImageModel('./', 'jpg', $imageOutputOptions);
13
        $this->assertEquals('./', $model->getImagePath());
14
        $this->assertEquals('jpg', $model->getFormat());
15
        $this->assertEquals($imageOutputOptions, $model->getImageOutputOptions());
16
        $imagine = new Imagine();
17
        $archos = $imagine->open('resources/Archos.jpg');
18
        $model = new ImageModel($archos, 'gif');
19
        $this->assertEquals($archos, $model->getImage());
20
        $this->assertEquals('gif', $model->getFormat());
21
    }
22
23
    public function testGetExceptionWithInvalidConstructorArgument()
24
    {
25
        $this->setExpectedException('HtImgModule\Exception\InvalidArgumentException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
26
        $model = new ImageModel(new \ArrayObject());
0 ignored issues
show
Documentation introduced by
new \ArrayObject() is of type object<ArrayObject>, but the function expects a object<Imagine\Image\ImageInterface>|string|null.

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
$model 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...
27
    }
28
}
29