GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#209)
by joseph
22:34
created

JsonSerializableTrait::jsonSerialize()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 12
c 1
b 0
f 1
nc 5
nop 0
dl 0
loc 18
ccs 0
cts 17
cp 0
crap 20
rs 9.8666
1
<?php declare(strict_types=1);
2
3
4
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Traits;
5
6
7
use EdmondsCommerce\DoctrineStaticMeta\DoctrineStaticMeta;
8
use Ramsey\Uuid\UuidInterface;
9
10
trait JsonSerializableTrait
11
{
12
    public function jsonSerialize(): array
13
    {
14
        $dsm         = static::getDoctrineStaticMeta();
15
        $toSerialize = [];
16
        $getters     = $dsm->getGetters();
17
        foreach ($getters as $getter) {
18
            $got = $this->$getter();
19
            if ($got instanceof UuidInterface) {
20
                $got = $got->toString();
21
            }
22
            if (false === is_scalar($got)) {
23
                continue;
24
            }
25
            $property               = $dsm->getPropertyNameFromGetterName($getter);
26
            $toSerialize[$property] = $got;
27
        }
28
29
        return $toSerialize;
30
    }
31
32
    abstract public static function getDoctrineStaticMeta(): DoctrineStaticMeta;
33
34
35
}