Completed
Push — master ( 5ac91e...39483e )
by Kirill
38:30
created

Deprecation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
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\SDL\Standard\Directives;
11
12
use Railt\SDL\Base\Definitions\BaseDirective;
13
use Railt\SDL\Contracts\Definitions\Directive\Location;
14
use Railt\SDL\Contracts\Dependent\ArgumentDefinition;
15
use Railt\SDL\Contracts\Document;
16
use Railt\SDL\Standard\Directives\Deprecation\Reason;
17
use Railt\SDL\Standard\StandardType;
18
19
/**
20
 * Class Deprecation
21
 *
22
 * @see https://github.com/graphql/graphql-js/pull/384
23
 */
24
final class Deprecation extends BaseDirective implements StandardType
25
{
26
    /**
27
     * Deprecation directive name
28
     */
29
    public const DIRECTIVE_TYPE_NAME = 'deprecated';
30
31
    /**
32
     * Deprecation reason argument
33
     */
34
    public const REASON_ARGUMENT = 'reason';
35
36
    /**
37
     * Deprecation constructor.
38
     * @param Document $document
39
     */
40 283
    public function __construct(Document $document)
41
    {
42 283
        $this->document          = $document;
43 283
        $this->name              = self::DIRECTIVE_TYPE_NAME;
44 283
        $this->deprecationReason = self::RFC_IMPL_DESCRIPTION;
45 283
        $this->locations         = Location::TARGET_GRAPHQL_SDL;
46
47 283
        $argument                              = $this->createReasonArgument();
48 283
        $this->arguments[$argument->getName()] = $argument;
49 283
    }
50
51
    /**
52
     * @return ArgumentDefinition
53
     */
54 283
    private function createReasonArgument(): ArgumentDefinition
55
    {
56 283
        return new Reason($this->getDocument(), $this);
57
    }
58
}
59