Test Failed
Push — master ( 1ff1d8...4bdf7b )
by Kirill
03:34
created

InputInvocation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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\Invocation;
11
12
use Railt\Reflection\Contracts\Document as DocumentInterface;
13
use Railt\Reflection\Contracts\Invocation\InputInvocation as InputInvocationInterface;
14
use Railt\Reflection\Contracts\TypeInterface as TypeInterface;
15
use Railt\Reflection\Document;
16
use Railt\Reflection\Invocation\Behaviour\HasArguments;
17
use Railt\Reflection\Type;
18
19
/**
20
 * Class InputInvocation
21
 */
22
class InputInvocation extends AbstractTypeInvocation implements InputInvocationInterface
23
{
24
    use HasArguments;
25
26
    /**
27
     * InputInvocation constructor.
28
     * @param Document|DocumentInterface $document
29
     * @param string|null $name
30
     */
31
    public function __construct(Document $document, string $name = null)
32
    {
33
        $this->document = $document;
34
        $this->name = $name;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getName(): string
41
    {
42
        return (string)($this->name ?? ':anonymous');
43
    }
44
45
    /**
46
     * @return TypeInterface
47
     */
48
    public static function getType(): TypeInterface
49
    {
50
        return Type::of(Type::INPUT_OBJECT);
51
    }
52
}
53