ValueObject   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 4 1
A equals() 0 12 3
A jsonUnserialize() 0 5 1
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