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.

ItineraryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 39.53 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_has_list_of_legs() 8 8 1
A it_is_same_value_as_itinerary_with_same_legs() 9 9 1
A it_is_not_same_value_as_itinerary_with_other_list_of_legs() 0 12 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
 * This file is part of the prooph/php-ddd-cargo-sample package.
4
 * (c) Alexander Miertsch <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
namespace CodelinerTest\CargoBackend\Domain\Model\Cargo;
10
11
use Codeliner\CargoBackend\Model\Cargo\Itinerary;
12
use CodelinerTest\CargoBackend\Fixture\LegFixture;
13
use CodelinerTest\CargoBackend\TestCase;
14
use Doctrine\Common\Collections\ArrayCollection;
15
use Codeliner\CargoBackend\Model\Cargo\Leg;
16
/**
17
 * Class ItineraryTest
18
 * 
19
 * @author Alexander Miertsch <[email protected]>
20
 */
21
class ItineraryTest extends TestCase
22
{
23
    /**
24
     * @test
25
     */
26 View Code Duplication
    public function it_has_list_of_legs()
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...
27
    {
28
        $legs = [LegFixture::get(LegFixture::HONGKONG_NEWYORK), LegFixture::get(LegFixture::NEWYORK_HAMBURG)];
29
30
        $itinerary = new Itinerary($legs);
0 ignored issues
show
Documentation introduced by
$legs is of type array<integer,object<Cod...el\\Cargo\\Leg>|null"}>, but the function expects a array<integer,object<Cod...ckend\Model\Cargo\Leg>>.

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...
31
        
32
        $this->assertSame($legs, $itinerary->legs());
33
    }
34
35
    /**
36
     * @test
37
     */
38 View Code Duplication
    public function it_is_same_value_as_itinerary_with_same_legs()
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...
39
    {
40
        $legs = [LegFixture::get(LegFixture::HONGKONG_NEWYORK), LegFixture::get(LegFixture::NEWYORK_HAMBURG)];
41
42
        $itinerary = new Itinerary($legs);
0 ignored issues
show
Documentation introduced by
$legs is of type array<integer,object<Cod...el\\Cargo\\Leg>|null"}>, but the function expects a array<integer,object<Cod...ckend\Model\Cargo\Leg>>.

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...
43
        $sameItinerary = new Itinerary($legs);
0 ignored issues
show
Documentation introduced by
$legs is of type array<integer,object<Cod...el\\Cargo\\Leg>|null"}>, but the function expects a array<integer,object<Cod...ckend\Model\Cargo\Leg>>.

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...
44
        
45
        $this->assertTrue($itinerary->sameValueAs($sameItinerary));
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function it_is_not_same_value_as_itinerary_with_other_list_of_legs()
52
    {
53
        $legs = [LegFixture::get(LegFixture::HONGKONG_NEWYORK), LegFixture::get(LegFixture::NEWYORK_HAMBURG)];
54
55
        $itinerary = new Itinerary($legs);
0 ignored issues
show
Documentation introduced by
$legs is of type array<integer,object<Cod...el\\Cargo\\Leg>|null"}>, but the function expects a array<integer,object<Cod...ckend\Model\Cargo\Leg>>.

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...
56
57
        $otherLegs = [LegFixture::get(LegFixture::HONGKONG_HAMBURG), LegFixture::get(LegFixture::HAMBURG_ROTTERDAM)];
58
59
        $otherItinerary = new Itinerary($otherLegs);
0 ignored issues
show
Documentation introduced by
$otherLegs is of type array<integer,object<Cod...el\\Cargo\\Leg>|null"}>, but the function expects a array<integer,object<Cod...ckend\Model\Cargo\Leg>>.

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...
60
61
        $this->assertFalse($itinerary->sameValueAs($otherItinerary));
62
    }
63
}
64