Passed
Push — master ( c39fb6...9e9a0d )
by Rafael
04:42
created

DefinitionNamespace   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
A getNode() 0 3 1
A getBundle() 0 3 1
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;
12
13
/**
14
 * DefinitionNamespace
15
 */
16
class DefinitionNamespace
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $bundle;
22
23
    /**
24
     * @var string
25
     */
26
    protected $node;
27
28
    /**
29
     * DefinitionNamespace constructor.
30
     *
31
     * @param string $bundle
32
     * @param string $node
33
     */
34
    public function __construct(?string $bundle, ?string $node)
35
    {
36
        if (!$bundle && !$node) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $node of type null|string is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
Bug Best Practice introduced by
The expression $bundle of type null|string is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
37
            throw new \InvalidArgumentException('Must define a bundle or node name to create a valid definition namespace');
38
        }
39
        $this->bundle = $bundle;
40
        $this->node = $node;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getBundle(): ?string
47
    {
48
        return $this->bundle;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getNode(): ?string
55
    {
56
        return $this->node;
57
    }
58
}
59