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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
c 1
b 0
f 1
dl 0
loc 23
ccs 0
cts 18
cp 0
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 18 4
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
}