Test Failed
Push — master ( d820d2...d59132 )
by Kirill
02:27
created

AbstractTypeDefinition::isBuiltin()   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
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
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;
11
12
use Railt\Reflection\Contracts\Definition\TypeDefinition;
13
use Railt\Reflection\Definition\Behaviour\HasDeprecation;
14
use Railt\Reflection\Definition\Behaviour\HasInheritance;
15
use Railt\Reflection\Invocation\Behaviour\HasDirectives;
16
17
/**
18
 * Class AbstractTypeDefinition
19
 */
20
abstract class AbstractTypeDefinition extends AbstractDefinition implements TypeDefinition
21
{
22
    use HasDirectives;
23
    use HasDeprecation;
24
    use HasInheritance;
25
26
    /**
27
     * @var string
28
     */
29
    protected $name;
30
31
    /**
32
     * @var string|null
33
     */
34
    protected $description;
35
36
    /**
37
     * AbstractTypeDefinition constructor.
38
     * @param Document|\Railt\Reflection\Contracts\Document $document
39
     * @param string $name
40
     */
41 9
    public function __construct(Document $document, string $name)
42
    {
43 9
        $this->name = $name;
44
45 9
        parent::__construct($document);
46 9
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getDescription(): string
52
    {
53
        return (string)$this->description;
54
    }
55
56
    /**
57
     * @param null|string $description
58
     * @return TypeDefinition|$this
59
     */
60 9
    public function withDescription(?string $description): TypeDefinition
61
    {
62 9
        $this->description = $description;
63
64 9
        return $this;
65
    }
66
67
    /**
68
     * @param string $name
69
     * @return TypeDefinition|$this
70
     */
71 8
    public function renameTo(string $name): TypeDefinition
72
    {
73 8
        $this->name = $name;
74
75 8
        return $this;
76
    }
77
78
    /**
79
     * @return string
80
     */
81 25
    public function getName(): string
82
    {
83 25
        return $this->name;
84
    }
85
86
    /**
87
     * @return bool
88
     */
89
    public function isBuiltin(): bool
90
    {
91
        return false;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function __toString(): string
98
    {
99
        return \sprintf('%s<%s>', $this->name ?? '?', static::getType());
100
    }
101
102
    /**
103
     * @return bool
104
     */
105
    public function isRenderable(): bool
106
    {
107
        return false;
108
    }
109
110
    /**
111
     * @return bool
112
     */
113
    public function isInputable(): bool
114
    {
115
        return false;
116
    }
117
}
118