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

JsonSerializableTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 22
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 3 1
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