Airport   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 76
loc 76
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A create() 4 4 1
A setTerminal() 6 6 1
A setGate() 6 6 1
A toArray() 11 11 1
A jsonSerialize() 4 4 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
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Message\Attachment\Template\Airline;
6
7 View Code Duplication
class Airport implements \JsonSerializable
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...
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $airportCode;
13
14
    /**
15
     * @var string
16
     */
17
    protected $city;
18
19
    /**
20
     * @var string
21
     */
22
    protected $terminal;
23
24
    /**
25
     * @var string
26
     */
27
    protected $gate;
28
29
    /**
30
     * Airport constructor.
31
     */
32 10
    public function __construct(string $airportCode, string $city)
33
    {
34 10
        $this->airportCode = $airportCode;
35 10
        $this->city = $city;
36 10
    }
37
38
    /**
39
     * @return \Kerox\Messenger\Model\Message\Attachment\Template\Airline\Airport
40
     */
41 10
    public static function create(string $airportCode, string $city): self
42
    {
43 10
        return new self($airportCode, $city);
44
    }
45
46
    /**
47
     * @return Airport
48
     */
49 10
    public function setTerminal(string $terminal): self
50
    {
51 10
        $this->terminal = $terminal;
52
53 10
        return $this;
54
    }
55
56
    /**
57
     * @return Airport
58
     */
59 10
    public function setGate(string $gate): self
60
    {
61 10
        $this->gate = $gate;
62
63 10
        return $this;
64
    }
65
66 5
    public function toArray(): array
67
    {
68
        $array = [
69 5
            'airport_code' => $this->airportCode,
70 5
            'city' => $this->city,
71 5
            'terminal' => $this->terminal,
72 5
            'gate' => $this->gate,
73
        ];
74
75 5
        return array_filter($array);
76
    }
77
78 5
    public function jsonSerialize(): array
79
    {
80 5
        return $this->toArray();
81
    }
82
}
83