Total Complexity | 5 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
12 | trait HasIdentification |
||
13 | { |
||
14 | 1 | use HasIdentifier; |
|
15 | 1 | use HasResourceType; |
|
16 | |||
17 | /** |
||
18 | * Get the identification ("type" and "id" members) as array |
||
19 | * |
||
20 | * @return array|null |
||
21 | */ |
||
22 | 66 | public function getIdentification(): ?array |
|
23 | { |
||
24 | 66 | if (!isset($this->id) && !isset($this->resourceType)) { |
|
25 | 12 | return null; |
|
26 | } |
||
27 | |||
28 | return [ |
||
29 | 54 | Members::TYPE => $this->resourceType, |
|
30 | 54 | Members::ID => ($this->id === null) ? null : strval($this->id) |
|
31 | ]; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Fill "type" and "id" members with fake values. |
||
36 | * |
||
37 | * @return static |
||
38 | */ |
||
39 | 39 | public function fakeIdentification() |
|
43 | } |
||
44 | } |
||
45 |