Completed
Push — master ( 60ed01...348d1d )
by Pol
11:09
created

ClosureObject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hash() 0 6 1
A __invoke() 0 4 1
A equals() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\valuewrapper\Object;
6
7
use drupol\valuewrapper\ValueInterface;
8
use SuperClosure\Serializer;
9
10
/**
11
 * Class ClosureObject
12
 */
13
class ClosureObject extends ObjectValue
14
{
15
    /**
16
     * ClosureObject constructor.
17
     *
18
     * @param \Closure $value
19 4
     */
20
    public function __construct(\Closure $value)
21 4
    {
22 4
        parent::__construct($value);
23
    }
24
25
    /**
26
     * {@inheritdoc}
27 1
     */
28
    public function hash(): string
29 1
    {
30
        $serializer = new Serializer();
31 1
32
        return $this->doHash($serializer->serialize($this->get()));
33
    }
34
35
    /**
36
     * {@inheritdoc}
37 1
     */
38
    public function __invoke()
39 1
    {
40
        return \call_user_func_array($this->get(), \func_get_args());
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function equals(ValueInterface $item, $strict = TRUE): bool {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected true, but found TRUE.
Loading history...
47
        return $this->hash() == $item->hash();
48
    }
49
}
50