Test Failed
Push — master ( 4bdf7b...97fe68 )
by Kirill
02:15
created

AbstractTypeInvocation::getDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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\Contracts\Document as DocumentInterface;
14
use Railt\Reflection\Contracts\Invocation\TypeInvocation;
15
use Railt\Reflection\Definition\Behaviour\HasName;
16
17
/**
18
 * Class AbstractTypeInvocation
19
 */
20
abstract class AbstractTypeInvocation extends AbstractDefinition implements TypeInvocation
21
{
22
    use HasName;
23
24
    /**
25
     * AbstractTypeInvocation constructor.
26
     * @param Document|DocumentInterface $document
27
     * @param string|null $name
28
     */
29 1
    public function __construct(Document $document, ?string $name)
30
    {
31 1
        $this->renameTo($name);
32 1
        parent::__construct($document);
33 1
    }
34
35
    /**
36
     * @return TypeDefinition
37
     * @throws \Railt\Io\Exception\ExternalFileException
38
     */
39 1
    public function getDefinition(): TypeDefinition
40
    {
41 1
        return $this->fetch($this->getName());
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function __toString(): string
48
    {
49
        return \sprintf('%s<%s>()', $this->getName(), static::getType());
50
    }
51
}
52