Test Failed
Push — master ( b79e07...d820d2 )
by Kirill
02:16
created

ScalarDefinition::isRenderable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Reflection\Definition;
11
12
use Railt\Reflection\AbstractTypeDefinition;
13
use Railt\Reflection\Contracts\Definition\ScalarDefinition as ScalarDefinitionInterface;
14
use Railt\Reflection\Contracts\Type as TypeInterface;
15
use Railt\Reflection\Type;
16
17
/**
18
 * Class ScalarDefinition
19
 */
20
class ScalarDefinition extends AbstractTypeDefinition implements ScalarDefinitionInterface
21
{
22
    /**
23
     * @return TypeInterface
24
     */
25 1
    public static function getType(): TypeInterface
26
    {
27 1
        return Type::of(Type::SCALAR);
28
    }
29
30
    /**
31
     * @param mixed $value
32
     * @return mixed
33
     */
34
    public function parse($value)
35
    {
36
        if ($parent = $this->getInheritedParent()) {
37
            $value = $parent->parse($value);
38
        }
39
40
        return $value;
41
    }
42
43
    /**
44
     * @param mixed $value
45
     * @return mixed
46
     */
47
    public function serialize($value)
48
    {
49
        if ($parent = $this->getParentInheritance()) {
0 ignored issues
show
Bug introduced by
The method getParentInheritance() does not seem to exist on object<Railt\Reflection\...ition\ScalarDefinition>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
            $value = $parent->serialize($value);
51
        }
52
53
        return $value;
54
    }
55
56
    /**
57
     * @return bool
58
     */
59
    public function isRenderable(): bool
60
    {
61
        return true;
62
    }
63
64
    /**
65
     * @return bool
66
     */
67
    public function isInputable(): bool
68
    {
69
        return true;
70
    }
71
}
72