ObjectValue::apply()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace drupol\valuewrapper\Object;
6
7
use drupol\valuewrapper\AbstractValue;
8
use drupol\valuewrapper\ValueInterface;
9
10
use function get_class;
11
12
/**
13
 * Class ObjectValue.
14
 */
15
abstract class ObjectValue extends AbstractValue implements ObjectValueInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 4
    public function apply(callable $callable)
21
    {
22 4
        $value = clone $this->value();
23
24 4
        return $callable($value);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 27
    public function class(): string
31
    {
32 27
        return get_class($this->value());
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 9
    public function equals(ValueInterface $item, bool $strict = true): bool
39
    {
40 9
        return $this->hash() === $item->hash();
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 19
    public function type(): string
47
    {
48 19
        return 'object';
49
    }
50
}
51