Completed
Push — master ( aff4a6...c9e866 )
by Samuel
9s
created

VehicleFactory::createTruck()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Vehicle\App\Factory;
4
5
use App\Common\App\Transformer\AppGlobalId;
6
use App\Vehicle\Domain\Car;
7
use App\Vehicle\Domain\Input\CarInput;
8
use App\Vehicle\Domain\Input\TruckInput;
9
use App\Vehicle\Domain\Truck;
10
use Overblog\GraphQLBundle\Definition\Argument;
11
12
class VehicleFactory
13
{
14
    /**
15
     * @param Argument $argument
16
     * @return CarInput
17
     */
18 View Code Duplication
    public static function createCarInput(Argument $argument): CarInput
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...
19
    {
20
        $input = $argument->offsetGet('input');
21
22
        return new CarInput(
23
            AppGlobalId::getIdFromGlobalId($input['id']),
24
            $input['manufacturer'],
25
            $input['model'],
26
            $input['seats_number']
27
        );
28
    }
29
30
    /**
31
     * @param CarInput $input
32
     * @return Car
33
     */
34
    public static function createCar(CarInput $input): Car
35
    {
36
        return new Car(
37
            $input->getId(),
38
            $input->getManufacturer(),
39
            $input->getModel(),
40
            $input->getSeatsNumber()
41
        );
42
    }
43
44
    /**
45
     * @param Argument $argument
46
     * @return TruckInput
47
     */
48 View Code Duplication
    public static function createTruckInput(Argument $argument): TruckInput
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...
49
    {
50
        $input = $argument->offsetGet('input');
51
52
        return new TruckInput(
53
            AppGlobalId::getIdFromGlobalId($input['id']),
54
            $input['manufacturer'],
55
            $input['model'],
56
            $input['maximum_load']
57
        );
58
    }
59
60
    /**
61
     * @param TruckInput $input
62
     * @return Truck
63
     */
64
    public static function createTruck(TruckInput $input): Truck
65
    {
66
        return new Truck(
67
            $input->getId(),
68
            $input->getManufacturer(),
69
            $input->getModel(),
70
            $input->getMaximumLoad()
71
        );
72
    }
73
}
74