Passed
Push — develop ( e2cf42...37d2d6 )
by Baptiste
03:06
created

Email::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace PersonalGalaxy\Identity\Specification\Identity;
5
6
use PersonalGalaxy\Identity\Entity\Identity\Email as Model;
7
use Innmind\Specification\{
8
    ComparatorInterface,
9
    SpecificationInterface,
10
    CompositeInterface,
11
    NotInterface,
12
};
13
14
final class Email implements ComparatorInterface
15
{
16
    private $value;
17
18 3
    public function __construct(Model $email)
19
    {
20 3
        $this->value = (string) $email;
21 3
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function property(): string
27
    {
28 1
        return 'email';
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    public function sign(): string
35
    {
36 1
        return '=';
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 1
    public function value()
43
    {
44 1
        return $this->value;
45
    }
46
47
    public function and(SpecificationInterface $specification): CompositeInterface
48
    {
49
        // not implemented
50
    }
1 ignored issue
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Innmind\Specification\CompositeInterface. 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...
51
52
    public function or(SpecificationInterface $specification): CompositeInterface
53
    {
54
        // not implemented
55
    }
1 ignored issue
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Innmind\Specification\CompositeInterface. 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...
56
57
    public function not(): NotInterface
58
    {
59
        // not implemented
60
    }
1 ignored issue
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return Innmind\Specification\NotInterface. 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...
61
}
62