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.

RouteCandidateDto   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 17.39 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 5
lcom 1
cbo 2
dl 8
loc 46
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLegs() 0 4 1
A setLegs() 0 8 2
A getArrayCopy() 8 15 2

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.
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
 * Date: 29.03.14 - 17:09
10
 */
11
declare(strict_types = 1);
12
13
namespace Codeliner\CargoBackend\Application\Booking\Dto;
14
15
use Assert\Assertion;
16
17
class RouteCandidateDto
18
{
19
    /**
20
     * @var LegDto[]
21
     */
22
    private $legs;
23
24
    /**
25
     * @param LegDto[] $legs
26
     */
27
    public function setLegs(array $legs)
28
    {
29
        foreach($legs as $leg) {
30
            Assertion::isInstanceOf($leg, LegDto::class);
31
        }
32
33
        $this->legs = $legs;
34
    }
35
36
    /**
37
     * @return LegDto[]
38
     */
39
    public function getLegs(): array
40
    {
41
        return $this->legs;
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    public function getArrayCopy(): array
48
    {
49
        $legsList = array();
50
51 View Code Duplication
        foreach ($this->getLegs() as $leg) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
52
            $legsList[] = array(
53
                'load_location'   => $leg->getLoadLocation(),
54
                'unload_location' => $leg->getUnloadLocation(),
55
                'load_time'       => $leg->getLoadTime(),
56
                'unload_time'     => $leg->getUnloadTime()
57
            );
58
        }
59
60
        return array('legs' => $legsList);
61
    }
62
}
63