Completed
Push — master ( 6f9efe...e7c2bb )
by Pol
14:34
created

AnonymousObject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 28
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hash() 0 8 2
A serialize() 0 3 1
A unserialize() 0 3 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
        throw new \BadMethodCallException('Unable to serialize this class.');
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function unserialize($serialized) {
37
        throw new \BadMethodCallException('Unable to unserialize this class.');
38
    }
39
}
40