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.

LogicalOrTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 5 5 1
A testLogicalAndIsTrueIfBothSidesAreTrue() 8 8 1
A logicalOrProvider() 9 9 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 {
3
    require_once 'LogicalEvaluatorTest.php';
4
}
5
6
namespace Tests\COG\ChronoShifter\Evaluator {
7
8
    use COG\ChronoShifter\Evaluator\Evaluator;
0 ignored issues
show
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
9
    use COG\ChronoShifter\Evaluator\LogicalOr;
0 ignored issues
show
Coding Style introduced by
USE declarations must go after the first namespace declaration
Loading history...
10
11
    /**
12
     * @author Kristjan Siimson <[email protected]>
13
     * @package Evaluator\Tests
14
     */
15 View Code Duplication
    class LogicalOrTest extends LogicalEvaluatorTest
0 ignored issues
show
Duplication introduced by
This class 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...
16
    {
17
        /**
18
         * @var Evaluator
19
         */
20
        protected $firstMock;
21
22
        /**
23
         * @var Evaluator
24
         */
25
        protected $secondMock;
26
27
        /**
28
         * @uses Evaluator
29
         */
30
        public function setUp()
31
        {
32
            $this->firstMock = $this->createMock();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock() of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<COG\ChronoShifter\Evaluator\Evaluator> of property $firstMock.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
33
            $this->secondMock = $this->createMock();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock() of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<COG\ChronoShifter\Evaluator\Evaluator> of property $secondMock.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34
        }
35
36
        /**
37
         * @dataProvider logicalOrProvider
38
         * @param bool $result
39
         * @param bool $left
40
         * @param bool $right
41
         */
42
        public function testLogicalAndIsTrueIfBothSidesAreTrue($result, $left, $right)
43
        {
44
            $this->mockReturns($this->firstMock, $left);
0 ignored issues
show
Documentation introduced by
$this->firstMock is of type object<COG\ChronoShifter\Evaluator\Evaluator>, but the function expects a object<PHPUnit_Framework_MockObject_MockObject>.

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...
45
            $this->mockReturns($this->secondMock, $right);
0 ignored issues
show
Documentation introduced by
$this->secondMock is of type object<COG\ChronoShifter\Evaluator\Evaluator>, but the function expects a object<PHPUnit_Framework_MockObject_MockObject>.

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...
46
47
            $evaluator = new LogicalOr($this->firstMock, $this->secondMock);
48
            $this->assertEquals($result, $evaluator->is('2014-01-01'));
49
        }
50
51
        public function logicalOrProvider()
52
        {
53
            return array(
54
                array(true, true, true),
55
                array(true, true, false),
56
                array(false, false, false),
57
                array(true, false, true)
58
            );
59
        }
60
    }
61
}