AttributeAscii   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 13
ccs 0
cts 4
cp 0
rs 10
c 2
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getNodeRepresentation() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace drupol\phpvfs\Exporter;
6
7
use drupol\phptree\Exporter\Ascii;
8
use drupol\phptree\Node\NodeInterface;
9
use drupol\phpvfs\Node\FilesystemNodeInterface;
10
11
/**
12
 * Class AttributeAscii.
13
 */
14
final class AttributeAscii extends Ascii
15
{
16
    /**
17
     * @param \drupol\phptree\Node\NodeInterface $node
18
     *   The node.
19
     *
20
     * @return string
21
     *   The node representation.
22
     */
23
    protected function getNodeRepresentation(NodeInterface $node): string
24
    {
25
        if ($node instanceof FilesystemNodeInterface) {
26
            return $node->getAttribute('label');
27
        }
0 ignored issues
show
Bug Best Practice introduced by
The function implicitly returns null when the if condition on line 25 is false. This is incompatible with the type-hinted return string. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
28
    }
29
}
30