Completed
Push — master ( 340eef...ea8a0d )
by Pol
14:55 queued 13:14
created

AnonymousObject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 30
ccs 4
cts 8
cp 0.5
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hash() 0 8 2
A serialize() 0 4 1
A unserialize() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\valuewrapper\Object;
6
7
use drupol\valuewrapper\Contract\Hashable;
8
9
/**
10
 * Class AnonymousObject
11
 */
12
class AnonymousObject extends ObjectValue
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 2
    public function hash(): string
18
    {
19 2
        if ($this->value() instanceof Hashable) {
20 1
            return $this->doHash($this->value()->hash());
21
        }
22
23 1
        throw new \Exception('The anonymous class must implement Hashable interface.');
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function serialize()
30
    {
31
        throw new \BadMethodCallException('Unable to serialize this class.');
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function unserialize($serialized)
38
    {
39
        throw new \BadMethodCallException('Unable to unserialize this class.');
40
    }
41
}
42