Completed
Pull Request — master (#3)
by Samuel
01:48
created

TruckInput::createFromArgument()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Vehicle\Domain\Input;
4
5
use App\Common\App\Transformer\AppGlobalId;
6
use App\Vehicle\Domain\VehicleAbstract;
7
use Overblog\GraphQLBundle\Definition\Argument;
8
9 View Code Duplication
class TruckInput extends VehicleAbstract
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...
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $id;
15
16
    /**
17
     * @var int
18
     */
19
    protected $maximumLoad;
20
21
    /**
22
     * @param string $id
23
     * @param string $manufacturer
24
     * @param string $model
25
     * @param int $maximumLoad
26
     */
27
    public function __construct(string $id, string $manufacturer, string $model, int $maximumLoad)
28
    {
29
        parent::__construct($id, $manufacturer, $model);
30
31
        $this->maximumLoad = $maximumLoad;
32
    }
33
34
    /**
35
     * @return int
36
     */
37
    public function getMaximumLoad(): int
38
    {
39
        return $this->maximumLoad;
40
    }
41
42
    /**
43
     * @param Argument $argument
44
     * @return TruckInput
45
     */
46
    public static function createFromArgument(Argument $argument): TruckInput
47
    {
48
        $input = $argument->offsetGet('input');
49
50
        return new self(
51
            AppGlobalId::getIdFromGlobalId($input['id']),
52
            $input['manufacturer'],
53
            $input['model'],
54
            $input['maximum_load']
55
        );
56
    }
57
}
58