Completed
Pull Request — master (#2)
by Pol
10:25 queued 09:08
created

ObjectValue   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 20%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 46
ccs 2
cts 10
cp 0.2
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A hash() 0 8 2
A equals() 0 4 1
A serialize() 0 4 1
A unserialize() 0 4 1
A class() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\valuewrapper\Object;
6
7
use drupol\valuewrapper\AbstractValue;
8
use drupol\valuewrapper\Contract\Hashable;
9
use drupol\valuewrapper\ValueInterface;
10
11
/**
12
 * Class ObjectValue
13
 */
14
abstract class ObjectValue extends AbstractValue
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function hash(): string
20
    {
21
        if ($this->get() instanceof Hashable) {
22
            return $this->doHash(\gettype($this->get()) . \get_class($this->get()) . $this->get()->hash());
23
        }
24
25
        return $this->doHash(\gettype($this->get()) . \get_class($this->get()) . \spl_object_hash($this->get()));
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 9
    public function equals(ValueInterface $item, $strict = true): bool
32
    {
33 9
        return $this->hash() == $item->hash();
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function serialize()
40
    {
41
        throw new \Exception('Not implemented');
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function unserialize($serialized)
48
    {
49
        throw new \Exception('Not implemented');
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function class()
0 ignored issues
show
Bug introduced by
Possible parse error: non-abstract method defined as abstract
Loading history...
56
    {
57
        return get_class($this->get());
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $this.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
58
    }
59
}
60