Completed
Pull Request — master (#51)
by Christoffer
02:05
created

VariableDefinitionWriter::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Language\Writer;
4
5
use Digia\GraphQL\Language\AST\Node\NodeInterface;
6
use Digia\GraphQL\Language\AST\Node\VariableDefinitionNode;
7
use function Digia\GraphQL\Language\wrap;
8
9
class VariableDefinitionWriter extends AbstractWriter
10
{
11
    /**
12
     * @param NodeInterface|VariableDefinitionNode $node
13
     * @inheritdoc
14
     */
15
    public function write(NodeInterface $node): string
16
    {
17
        $variable     = $this->printNode($node->getVariable());
0 ignored issues
show
Bug introduced by
The method getVariable() does not exist on Digia\GraphQL\Language\AST\Node\NodeInterface. It seems like you code against a sub-type of Digia\GraphQL\Language\AST\Node\NodeInterface such as Digia\GraphQL\Language\A...\VariableDefinitionNode. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $variable     = $this->printNode($node->/** @scrutinizer ignore-call */ getVariable());
Loading history...
18
        $type         = $this->printNode($node->getType());
0 ignored issues
show
Bug introduced by
The method getType() does not exist on Digia\GraphQL\Language\AST\Node\NodeInterface. It seems like you code against a sub-type of Digia\GraphQL\Language\AST\Node\NodeInterface such as Digia\GraphQL\Language\A...ationTypeDefinitionNode or Digia\GraphQL\Language\A...nputValueDefinitionNode or Digia\GraphQL\Language\A...ode\FieldDefinitionNode or Digia\GraphQL\Language\A...\VariableDefinitionNode or Digia\GraphQL\Language\AST\Node\ListTypeNode or Digia\GraphQL\Language\AST\Node\NonNullTypeNode. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        $type         = $this->printNode($node->/** @scrutinizer ignore-call */ getType());
Loading history...
19
        $defaultValue = $this->printNode($node->getDefaultValue());
0 ignored issues
show
Bug introduced by
The method getDefaultValue() does not exist on Digia\GraphQL\Language\AST\Node\NodeInterface. It seems like you code against a sub-type of Digia\GraphQL\Language\AST\Node\NodeInterface such as Digia\GraphQL\Language\A...nputValueDefinitionNode or Digia\GraphQL\Language\A...\VariableDefinitionNode. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $defaultValue = $this->printNode($node->/** @scrutinizer ignore-call */ getDefaultValue());
Loading history...
20
21
        return $variable . ': ' . $type . wrap(' = ', $defaultValue);
22
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function supportsWriter(NodeInterface $node): bool
28
    {
29
        return $node instanceof VariableDefinitionNode;
30
    }
31
}
32