Completed
Push — master ( a787fa...dc9af5 )
by Vincent
05:35
created

HasIdentification::setId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiAssert\Factory;
6
7
use VGirol\JsonApiAssert\Members;
8
9
trait HasIdentification
10
{
11
    use HasResourceType;
12
13
    public $id;
14
15
    /**
16
     * Undocumented function
17
     *
18
     * @param int|string|null $resourceId
19
     * @return static
20
     */
21
    public function setId($resourceId)
22
    {
23
        $this->id = $resourceId;
24
25
        return $this;
26
    }
27
28
    public function getIdentification(): ?array
29
    {
30
        if (!isset($this->id) && !isset($this->resourceType)) {
31
            return null;
32
        }
33
34
        return [
35
            Members::TYPE => $this->resourceType,
36
            Members::ID => strval($this->id)
37
        ];
38
    }
39
}
40