Completed
Push — master ( 2a1736...a76588 )
by Pol
03:14 queued 01:51
created

ClosureObject::equals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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
     */
20 5
    public function __construct(\Closure $value)
21
    {
22 5
        parent::__construct($value);
23 5
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 2
    public function hash(): string
29
    {
30 2
        $serializer = new Serializer();
31
32 2
        return $this->doHash($serializer->serialize($this->get()));
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function __invoke()
39
    {
40 1
        return \call_user_func_array($this->get(), \func_get_args());
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 1
    public function equals(ValueInterface $item, $strict = true): bool
47
    {
48 1
        return $this->hash() == $item->hash();
49
    }
50
}
51