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.

ValueObjectComplex   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 35
ccs 12
cts 12
cp 1
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A guard() 0 4 2
A getValue() 0 5 1
A __toString() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DBUnt1tled\VO\VObjects;
6
7
use DBUnt1tled\VO\Exception\InvalidVOArgumentException;
8
9
abstract class ValueObjectComplex extends ValueObject
10
{
11
12
    /**
13
     * @param mixed $value
14
     * @param mixed ...$other
15
     * @throws \ReflectionException
16
     */
17 25
    public function guard($value, ...$other): void
18
    {
19 25
        if (!$value instanceof ValueObjectInterface) {
20 1
            throw new InvalidVOArgumentException(sprintf('%s cannot create by base type.', $this->getReflection()->getShortName()), $this->value);
21
        }
22 24
    }
23
24
    /**
25
     * @return mixed
26
     */
27 11
    public function getValue()
28
    {
29
        /** @var ValueObjectInterface $vo */
30 11
        $vo = parent::getValue();
31 11
        return $vo->getValue();
32
    }
33
34
    /**
35
     * @return string
36
     */
37 2
    public function __toString(): string
38
    {
39 2
        $vo = $this->getValue();
40 2
        if (is_scalar($vo)) {
41 1
            return (string)$vo;
42
        }
43 1
        return (string)json_encode($vo, 320);
44
    }
45
}
46