DefaultAdrUnit   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 17
c 1
b 0
f 1
dl 0
loc 65
ccs 27
cts 27
cp 1
rs 10
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getTunnelCode() 0 3 1
A getCarrier() 0 3 1
A __construct() 0 10 1
A getTransportCategory() 0 3 1
A getClass() 0 3 1
A getCode() 0 3 1
A getName() 0 3 1
A getPackaging() 0 3 1
A getId() 0 3 1
A __toArray() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Inspirum\Balikobot\Model\AdrUnit;
6
7
use Inspirum\Arrayable\BaseModel;
8
9
/**
10
 * @extends \Inspirum\Arrayable\BaseModel<string,mixed>
11
 */
12
final class DefaultAdrUnit extends BaseModel implements AdrUnit
13
{
14 4
    public function __construct(
15
        private readonly string $carrier,
16
        private readonly string $id,
17
        private readonly string $code,
18
        private readonly string $name,
19
        private readonly string $class,
20
        private readonly ?string $packaging,
21
        private readonly ?string $tunnelCode,
22
        private readonly string $transportCategory,
23
    ) {
24 4
    }
25
26 1
    public function getCarrier(): string
27
    {
28 1
        return $this->carrier;
29
    }
30
31 1
    public function getId(): string
32
    {
33 1
        return $this->id;
34
    }
35
36 1
    public function getCode(): string
37
    {
38 1
        return $this->code;
39
    }
40
41 1
    public function getName(): string
42
    {
43 1
        return $this->name;
44
    }
45
46 1
    public function getClass(): string
47
    {
48 1
        return $this->class;
49
    }
50
51 1
    public function getPackaging(): ?string
52
    {
53 1
        return $this->packaging;
54
    }
55
56 1
    public function getTunnelCode(): ?string
57
    {
58 1
        return $this->tunnelCode;
59
    }
60
61 1
    public function getTransportCategory(): string
62
    {
63 1
        return $this->transportCategory;
64
    }
65
66
    /** @inheritDoc */
67 2
    public function __toArray(): array
68
    {
69 2
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array('id' => $th...his->transportCategory) returns the type array<string,null|string> which is incompatible with the return type mandated by Inspirum\Arrayable\BaseModel::__toArray() of Inspirum\Arrayable\TValue[].

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
70 2
            'id' => $this->id,
71 2
            'code' => $this->code,
72 2
            'name' => $this->name,
73 2
            'class' => $this->class,
74 2
            'packaging' => $this->packaging,
75 2
            'tunnelCode' => $this->tunnelCode,
76 2
            'transportCategory' => $this->transportCategory,
77 2
        ];
78
    }
79
}
80