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

ClosureObject::equals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
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