Test Failed
Push — master ( bc5b04...424213 )
by Hannes
03:21
created

NamespaceName::getNamespaceName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace hanneskod\readmetester\Name;
6
7
final class NamespaceName implements NameInterface
8
{
9
    /** @var string */
10
    private $namespace;
11
12
    public function __construct(string $namespace)
13
    {
14
        $this->namespace = $namespace;
15
    }
16
17
    public function getNamespaceName(): string
18
    {
19
        return $this->namespace;
20
    }
21
22
    public function getShortName(): string
23
    {
24
        throw new \RuntimeException('Unable to read short name from namespace');
25
    }
26
27
    public function getName(): string
28
    {
29
        $this->getShortName();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which 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...
30
    }
31
}
32