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
20:17
created

JsonSerializableTrait::jsonSerialize()   B

Complexity

Conditions 8
Paths 12

Size

Total Lines 31
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 72

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 8
eloc 20
nc 12
nop 0
dl 0
loc 31
ccs 0
cts 29
cp 0
crap 72
rs 8.4444
c 1
b 0
f 1
1
<?php declare(strict_types=1);
2
3
4
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Traits;
5
6
7
use Doctrine\Common\Collections\Collection;
8
use Doctrine\ORM\Proxy\Proxy;
9
use EdmondsCommerce\DoctrineStaticMeta\DoctrineStaticMeta;
10
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
11
use Ramsey\Uuid\UuidInterface;
12
13
trait JsonSerializableTrait
14
{
15
    public function jsonSerialize(): array
16
    {
17
        $dsm         = static::getDoctrineStaticMeta();
18
        $toSerialize = [];
19
        $getters     = $dsm->getGetters();
20
        foreach ($getters as $getter) {
21
            /** @var mixed $got */
22
            $got = $this->$getter();
23
            if ($got instanceof EntityInterface) {
24
                continue;
25
            }
26
            if ($got instanceof Collection) {
27
                continue;
28
            }
29
            if ($got instanceof Proxy) {
30
                continue;
31
            }
32
            if ($got instanceof UuidInterface) {
33
                $got = $got->toString();
34
            }
35
            if (method_exists($got, '__toString')) {
36
                $got = (string)$got;
37
            }
38
            if (false === is_scalar($got)) {
39
                continue;
40
            }
41
            $property               = $dsm->getPropertyNameFromGetterName($getter);
42
            $toSerialize[$property] = $got;
43
        }
44
45
        return $toSerialize;
46
    }
47
48
    abstract public static function getDoctrineStaticMeta(): DoctrineStaticMeta;
49
50
51
}