Jsonable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 5
c 3
b 1
f 0
dl 0
loc 14
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A asJson() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AhmadMayahi\Vision\Traits;
6
7
trait Jsonable
8
{
9
    public function asJson(): string
10
    {
11
        $res = $this->detect();
12
13
        if (is_iterable($res)) {
14
            return json_encode(iterator_to_array($res));
15
        }
16
17
        return json_encode([]);
18
    }
19
20
    abstract public function detect(): mixed;
21
}
22