Completed
Push — master ( e238c3...0855a3 )
by Pol
13:48 queued 01:17
created

ObjectValue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 33.33%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hash() 0 8 2
A doHash() 0 4 1
1
<?php
2
3
namespace drupol\valuewrapper\Object;
4
5
use drupol\valuewrapper\AbstractValue;
6
use drupol\valuewrapper\Hashable;
7
8
/**
9
 * Class ObjectValue
10
 */
11
class ObjectValue extends AbstractValue
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function hash(): string
17
    {
18
        if ($this->value instanceof Hashable) {
19
            return $this->doHash(gettype($this->value) . get_class($this->value) . $this->value->hash());
20
        }
21
22
        return $this->doHash(gettype($this->value) . get_class($this->value) . \spl_object_hash($this->value));
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 3
    protected function doHash(string $string) : string
29
    {
30 3
        return \sha1($string);
31
    }
32
}
33