Completed
Push — master ( e7c2bb...340eef )
by Pol
14:36
created

ObjectValue::type()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 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 implements ObjectValueInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function hash(): string
20
    {
21
        if ($this->value() instanceof Hashable) {
22
            return $this->doHash(\gettype($this->value()) . \get_class($this->value()) . $this->value()->hash());
23
        }
24
25
        return $this->doHash(\gettype($this->value()) . \get_class($this->value()) . \spl_object_hash($this->value()));
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    public function equals(ValueInterface $item, $strict = true): bool
32
    {
33 2
        return $this->hash() == $item->hash();
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function class(): string {
0 ignored issues
show
Bug introduced by
Possible parse error: non-abstract method defined as abstract
Loading history...
40
        return \get_class($this->value());
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...
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function type(): string {
47
        return 'object';
48
    }
49
}
50