NodeAwareDefinitionTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 29
c 0
b 0
f 0
ccs 6
cts 7
cp 0.8571
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getNode() 0 3 1
A setNode() 0 9 3
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Definition\Traits;
12
13
use Ynlo\GraphQLBundle\Definition\NodeAwareDefinitionInterface;
14
15
/**
16
 * Trait TypeAwareDefinitionTrait
17
 */
18
trait NodeAwareDefinitionTrait
19
{
20
    /**
21
     * @var string
22
     */
23
    protected $node;
24
25
    /**
26
     * @return mixed
27
     */
28 10
    public function getNode(): ?string
29
    {
30 10
        return $this->node;
31
    }
32
33
    /**
34
     * @param string $node
35
     *
36
     * @return NodeAwareDefinitionInterface
37
     */
38 36
    public function setNode(?string $node): NodeAwareDefinitionInterface
39
    {
40 36
        if ($node && !preg_match('/\w+/', $node)) {
41
            throw new \InvalidArgumentException('Invalid node name');
42
        }
43
44 36
        $this->node = $node;
45
46 36
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Ynlo\GraphQLBundle\Defin...odeAwareDefinitionTrait which is incompatible with the type-hinted return Ynlo\GraphQLBundle\Defin...wareDefinitionInterface.
Loading history...
47
    }
48
}
49