Completed
Push — master ( e238c3...0855a3 )
by Pol
13:48 queued 01:17
created

AbstractValue::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace drupol\valuewrapper;
4
5
/**
6
 * Class AbstractValue
7
 */
8
abstract class AbstractValue implements ValueInterface
9
{
10
    /**
11
     * @var mixed
12
     */
13
    protected $value;
14
15
    /**
16
     * AbstractValue constructor.
17
     *
18
     * @param mixed $value
19
     */
20 23
    public function __construct($value)
21
    {
22 23
        $this->value = $value;
23 23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 1
    public function get()
29
    {
30 1
        return $this->value;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function equals(ValueInterface $item, $strict = true) : bool
37
    {
38
        return ($strict === true) ?
39
            $this === $item:
40
            $this == $item;
41
    }
42
43
    /**
44
     * @param string $string
45
     *   The string to hash.
46
     *
47
     * @return string
48
     *   The string's hash.
49
     */
50
    protected function doHash(string $string) : string
51
    {
52
        return \sha1($string);
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function __invoke()
59
    {
60
        return $this->value;
61
    }
62
}
63