NullValue::sameValueAs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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