Passed
Push — master ( c1150e...84b7ab )
by Michael
02:30
created

ResourceBehaviour   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getType() 0 4 1
A resourceToArray() 0 7 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Document\Behaviour;
5
6
/**
7
 * Class ResourceBehaviour
8
 *
9
 * @see http://jsonapi.org/format/#document-resource-objects
10
 * @see http://jsonapi.org/format/#document-resource-identifier-objects
11
 *
12
 * @package Mikemirten\Component\JsonApi\Document\Behaviour
13
 */
14
trait ResourceBehaviour
15
{
16
    /**
17
     * ID of resource
18
     *
19
     * @var string
20
     */
21
    protected $id;
22
23
    /**
24
     * Type of resource
25
     *
26
     * @var string
27
     */
28
    protected $type;
29
30
    /**
31
     * Get ID of resource
32
     *
33
     * @return string
34
     */
35
    public function getId(): string
36
    {
37
        return $this->id;
38
    }
39
40
    /**
41
     * Get type of resource
42
     *
43
     * @return string
44
     */
45
    public function getType(): string
46
    {
47
        return $this->type;
48
    }
49
50
    /**
51
     * Cast resource to an array
52
     *
53
     * @return array
54
     */
55
    protected function resourceToArray(): array
56
    {
57
        return [
58
            'id'   => $this->getId(),
59
            'type' => $this->getType()
60
        ];
61
    }
62
}