NullValue   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 47
ccs 8
cts 10
cp 0.8
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A fromNative() 0 4 1
A create() 0 4 1
A sameValueAs() 0 4 1
A __toString() 0 4 1
A jsonSerialize() 0 4 1
1
<?php
2
3
namespace ValueObjects\NullValue;
4
5
use ValueObjects\Util\Util;
6
use ValueObjects\ValueObjectInterface;
7
8
class NullValue implements ValueObjectInterface
9
{
10
    /**
11
     * @throws \BadMethodCallException
12
     */
13 1
    public static function fromNative()
14
    {
15 1
        throw new \BadMethodCallException('Cannot create a NullValue object via this method.');
16
    }
17
18
    /**
19
     * Returns a new NullValue object
20
     *
21
     * @return static
22
     */
23 5
    public static function create()
24
    {
25 5
        return new static();
26
    }
27
28
    /**
29
     * Tells whether two objects are both NullValue
30
     * @param  ValueObjectInterface $null
31
     * @return bool
32
     */
33 5
    public function sameValueAs(ValueObjectInterface $null)
34
    {
35 5
        return Util::classEquals($this, $null);
36
    }
37
38
    /**
39
     * Returns a string representation of the NullValue object
40
     *
41
     * @return string
42
     */
43 1
    public function __toString()
44
    {
45 1
        return \strval(null);
46
    }
47
48
    function jsonSerialize()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for jsonSerialize.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
49
    {
50
        return null;
51
    }
52
53
54
}
55