Completed
Push — master ( 96b2f8...da2c9c )
by Kirill
05:58
created

AbstractTypeDefinition::getDescription()   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 4
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\Invocation\Behaviour\HasDirectives;
15
16
/**
17
 * Class AbstractTypeDefinition
18
 */
19
abstract class AbstractTypeDefinition extends AbstractDefinition implements TypeDefinition
20
{
21
    use HasDirectives;
22
    use HasDeprecation;
23
24
    /**
25
     * @var string
26
     */
27
    protected $name;
28
29
    /**
30
     * @var string|null
31
     */
32
    protected $description;
33
34
    /**
35
     * AbstractTypeDefinition constructor.
36
     * @param Document $document
37
     * @param int $offset
38
     * @param string $name
39
     */
40
    public function __construct(Document $document, int $offset, string $name)
41
    {
42
        $this->name = $name;
43
        parent::__construct($document, $offset);
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getDescription(): string
50
    {
51
        return (string)$this->description;
52
    }
53
54
    /**
55
     * @param null|string $description
56
     */
57
    public function setDescription(?string $description): void
58
    {
59
        $this->description = $description;
60
    }
61
62
    /**
63
     * @param TypeDefinition $definition
64
     * @return bool
65
     */
66
    public function instanceOf(TypeDefinition $definition): bool
67
    {
68
        return $this instanceof $definition;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function getName(): string
75
    {
76
        return $this->name;
77
    }
78
}
79