JsonSerializableTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 14 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Mcneely\Core\Traits;
6
7
use ArrayIterator;
8
use Mcneely\Core\CoreObject;
9
10
/**
11
 * Trait JsonSerializableTrait.
12
 *
13
 * @package Mcneely\Core\Traits
14
 *
15
 * @method CoreObject CoreTrait_getCoreObject()
16
 * @method mixed fireEvents_CoreTrait($eventClassObject, $eventImmediateClass, $eventMethod, $eventTrait)
17
 */
18
trait JsonSerializableTrait
19
{
20
    /**
21
     * @return mixed
22
     */
23 1
    public function jsonSerialize(): array
24
    {
25 1
        $this->CoreTrait_fireEvents($this, __CLASS__, __METHOD__, __TRAIT__);
0 ignored issues
show
Bug introduced by
It seems like CoreTrait_fireEvents() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $this->/** @scrutinizer ignore-call */ 
26
               CoreTrait_fireEvents($this, __CLASS__, __METHOD__, __TRAIT__);
Loading history...
26
27
        $object = $this
28 1
            ->CoreTrait_getCoreObject()
29 1
            ->unWrap(ArrayIterator::class)
30
        ;
31
32 1
        if ($object instanceof ArrayIterator) {
33 1
            return $object->getArrayCopy();
34
        }
35
36 1
        return (array) $object;
37
    }
38
}
39