Passed
Branch develop (2fd4b5)
by Alexey
01:46
created

JsonSerializableTrait::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Nelexa\GPlay\Model;
5
6
trait JsonSerializableTrait
7
{
8
    /**
9
     * Returns class properties as an array.
10
     *
11
     * @return array
12
     */
13
    abstract public function asArray(): array;
14
15
    /**
16
     * Specify data which should be serialized to JSON.
17
     *
18
     * Serializes the object to a value that can be serialized natively by `json_encode()`.
19
     *
20
     * @return mixed Returns data which can be serialized by `json_encode()`,
21
     *     which is a value of any type other than a `resource`.
22
     *
23
     * @link https://php.net/manual/en/jsonserializable.jsonserialize.php JsonSerializable::jsonSerialize
24
     */
25
    public function jsonSerialize()
26
    {
27
        return $this->asArray();
28
    }
29
}
30