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

NamespaceName   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getShortName() 0 3 1
A __construct() 0 3 1
A getNamespaceName() 0 3 1
A getName() 0 3 1
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