Completed
Pull Request — master (#2)
by Pol
06:54 queued 05:41
created

ObjectValue::class()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
nc 1
cc 1
nop 0
crap 2
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 5
    public function equals(ValueInterface $item, $strict = true): bool
32
    {
33 5
        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