Completed
Push — feature/pilot_information ( 13ff1e...cc067b )
by Laurent
01:46
created

LicenceNumberTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getLicence() 0 3 1
A empty() 0 3 1
A create() 0 3 1
1
<?php
2
3
4
namespace FlightLog\Domain\Pilot\ValueObject;
5
6
7
trait LicenceNumberTrait
8
{
9
    /**
10
     * @var string
11
     */
12
    private $licence;
13
14
    private function __construct(string $licence)
15
    {
16
        $this->licence = $licence;
17
    }
18
19
    public function getLicence(): string{
20
        return $this->licence;
21
    }
22
23
    /**
24
     * @return LicenceNumberTrait|static
0 ignored issues
show
Comprehensibility Bug introduced by
The return type LicenceNumberTrait is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
25
     */
26
    public static function empty(): self{
27
        return new self('');
28
    }
29
30
    /**
31
     * @param string $licence
32
     *
33
     * @return LicenceNumberTrait|static
0 ignored issues
show
Comprehensibility Bug introduced by
The return type LicenceNumberTrait is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
34
     */
35
    public static function create(string $licence): self{
36
        return new self($licence);
37
    }
38
39
}