ValueObject::equals()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php namespace C4tech\RayEmitter\Domain;
2
3
use C4tech\RayEmitter\Contracts\Domain\ValueObject as ValueObjectInterface;
4
5
abstract class ValueObject implements ValueObjectInterface
6
{
7
    /**
8
     * @inheritDoc
9
     */
10 3
    public function equals(ValueObjectInterface $other)
11
    {
12 3
        if (get_class($other) !== get_class($this)) {
13 1
            return false;
14
        }
15
16 2
        if ($other->getValue() === $this->getValue()) {
17 1
            return true;
18
        }
19
20 1
        return false;
21
    }
22
23
    /**
24
     * @inheritDoc
25
     */
26 2
    public function jsonSerialize()
27
    {
28 2
        return $this->getValue();
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34 2
    public static function jsonUnserialize($json)
35
    {
36 2
        $data = json_decode($json);
37 2
        return new static($data);
0 ignored issues
show
Unused Code introduced by
The call to ValueObject::__construct() has too many arguments starting with $data.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
38
    }
39
}
40