Completed
Push — feature/fixing_cost ( ef981e )
by Laurent
01:53
created

Id::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\Common\ValueObject;
5
6
7
trait Id
8
{
9
    /**
10
     * @var int
11
     */
12
    private $id;
13
14
    /**
15
     * @param int $id
16
     */
17
    public function __construct($id)
18
    {
19
        $this->id = $id;
20
    }
21
22
    /**
23
     * @param int $id
24
     *
25
     * @return Id
0 ignored issues
show
Comprehensibility Bug introduced by
The return type Id 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...
26
     */
27
    public static function create($id){
28
        return new self($id);
29
    }
30
31
    /**
32
     * @return int
33
     */
34
    public function getId()
35
    {
36
        return $this->id;
37
    }
38
39
}