JsonSerializableTrait::jsonSerialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 0
cts 5
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
crap 6
1
<?php
2
3
namespace BrainExe\Core\Traits;
4
5
/**
6
 * @api
7
 */
8
trait JsonSerializableTrait
9
{
10
    /**
11
     * @return array
12
     */
13
    public function jsonSerialize() : array
14
    {
15
        $data = [];
16
17
        foreach ($this as $key => $value) {
0 ignored issues
show
Bug introduced by
The expression $this of type this<BrainExe\Core\Traits\JsonSerializableTrait> is not traversable.
Loading history...
18
            $data[$key] = $value;
19
        }
20
21
        return $data;
22
    }
23
}
24