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.

CargoRoutingDtoAssembler::toDto()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 13

Duplication

Lines 10
Ratio 47.62 %
Metric Value
dl 10
loc 21
rs 9.3142
cc 2
eloc 13
nc 2
nop 1
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 - 18:21
10
 */
11
declare(strict_types = 1);
12
13
namespace Codeliner\CargoBackend\Application\Booking\Assembler;
14
15
use Codeliner\CargoBackend\Application\Booking\Dto\CargoRoutingDto;
16
use Codeliner\CargoBackend\Application\Booking\Dto\LegDto;
17
use Codeliner\CargoBackend\Model\Cargo\Cargo;
18
19
/**
20
 * Class CargoRoutingDtoAssembler
21
 *
22
 * @package Codeliner\CargoBackend\Application\Booking\Assembler
23
 * @author Alexander Miertsch <[email protected]>
24
 */
25
class CargoRoutingDtoAssembler 
26
{
27
    /**
28
     * @param Cargo $aCargo
29
     * @return CargoRoutingDto
30
     */
31
    public function toDto(Cargo $aCargo): CargoRoutingDto
32
    {
33
        $cargoRoutingDto = new CargoRoutingDto();
34
35
        $cargoRoutingDto->setTrackingId($aCargo->trackingId()->toString());
36
        $cargoRoutingDto->setOrigin($aCargo->origin());
37
        $cargoRoutingDto->setFinalDestination($aCargo->routeSpecification()->destination());
38
39 View Code Duplication
        foreach ($aCargo->itinerary()->legs() 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...
40
            $legDto = new LegDto();
41
42
            $legDto->setLoadLocation($leg->loadLocation());
43
            $legDto->setUnloadLocation($leg->unloadLocation());
44
            $legDto->setLoadTime($leg->loadTime()->format(\DateTime::ATOM));
45
            $legDto->setUnloadTime($leg->unloadTime()->format(\DateTime::ATOM));
46
47
            $cargoRoutingDto->addLeg($legDto);
48
        }
49
50
        return $cargoRoutingDto;
51
    }
52
}
53