Completed
Pull Request — master (#119)
by Toby
02:47
created

ResourceIdentifier::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of JSON-API.
5
 *
6
 * (c) Toby Zerner <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tobscure\JsonApi;
13
14
use JsonSerializable;
15
16
class ResourceIdentifier implements JsonSerializable
17
{
18
    use MetaTrait;
19
20
    private $type;
21
    private $id;
22
23 18
    public function __construct($type, $id)
24
    {
25 18
        $this->type = $type;
26 18
        $this->id = $id;
27 18
    }
28
29 18
    public function jsonSerialize()
30
    {
31 18
        return array_filter(
32
            [
33 18
                'type' => $this->type,
34 18
                'id' => $this->id,
35 18
                'meta' => $this->meta
36 18
            ]
37 18
        );
38
    }
39
}
40