Completed
Push — master ( 883f28...097345 )
by Vincent
03:45 queued 11s
created

HasIdentification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getIdentification() 0 9 3
A fakeIdentification() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
use VGirol\JsonApiFaker\Members;
8
9
trait HasIdentification
10
{
11
    use HasResourceType;
12
    use HasIdentifier;
13
14
    /**
15
     * Undocumented function
16
     *
17
     * @return array|null
18
     */
19 22
    public function getIdentification(): ?array
20
    {
21 22
        if (!isset($this->id) && !isset($this->resourceType)) {
22 4
            return null;
23
        }
24
25
        return [
26 18
            Members::TYPE => $this->resourceType,
27 18
            Members::ID => strval($this->id)
28
        ];
29
    }
30
31
    /**
32
     * Undocumented function
33
     *
34
     * @return static
35
     */
36 10
    public function fakeIdentification()
37
    {
38 10
        return $this->fakeResourceType()
39 10
            ->fakeIdentifier();
40
    }
41
}
42