Completed
Pull Request — master (#119)
by Toby
03:16
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
use Tobscure\JsonApi\MetaTrait;
16
17
class ResourceIdentifier implements JsonSerializable
18
{
19
    use MetaTrait;
20
21
    private $type;
22
    private $id;
23
24 15
    public function __construct($type, $id)
25
    {
26 15
        $this->type = $type;
27 15
        $this->id = $id;
28 15
    }
29
30 15
    public function jsonSerialize()
31
    {
32 15
        return array_filter(
33
            [
34 15
                'type' => $this->type,
35 15
                'id' => $this->id,
36 15
                'meta' => $this->meta
37 15
            ]
38 15
        );
39
    }
40
}
41