JsonSerializableTrait::__debugInfo()   A
last analyzed

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
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (c) Ne-Lexa
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 *
11
 * @see https://github.com/Ne-Lexa/google-play-scraper
12
 */
13
14
namespace Nelexa\GPlay\Model;
15
16
/**
17
 * Trait JsonSerializableTrait.
18
 */
19
trait JsonSerializableTrait
20
{
21
    /**
22
     * @return array
23
     *
24
     * @internal
25
     */
26
    public function __debugInfo(): array
27
    {
28
        return $this->asArray();
29
    }
30
31
    /**
32
     * Returns class properties as an array.
33
     *
34
     * @return array
35
     */
36
    abstract public function asArray(): array;
37
38
    /**
39
     * Specify data which should be serialized to JSON.
40
     *
41
     * Serializes the object to a value that can be serialized natively by `json_encode()`.
42
     *
43
     * @return array returns data which can be serialized by `json_encode()`,
44
     *               which is a value of any type other than a `resource`
45
     *
46
     * @see https://php.net/manual/en/jsonserializable.jsonserialize.php JsonSerializable::jsonSerialize
47
     */
48
    public function jsonSerialize(): array
49
    {
50
        return $this->asArray();
51
    }
52
}
53