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

LicenceNumberTrait::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
}