BoolMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * File was created 30.09.2015 07:58
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Core\Codec\Property;
7
8
use PeekAndPoke\Component\Slumber\Annotation\Slumber\AsBool;
9
use PeekAndPoke\Component\Slumber\Core\Codec\Awaker;
10
use PeekAndPoke\Component\Slumber\Core\Codec\Slumberer;
11
12
/**
13
 * @author Karsten J. Gerber <[email protected]>
14
 */
15
class BoolMapper extends AbstractPropertyMapper
16
{
17
    /** @var AsBool */
18
    private $options;
19
20
    /**
21
     * C'tor.
22
     *
23
     * @param AsBool $options
24
     */
25 23
    public function __construct(AsBool $options)
26
    {
27 23
        $this->options = $options;
28 23
    }
29
30
    /**
31
     * @return AsBool
32
     */
33 1
    public function getOptions()
34
    {
35 1
        return $this->options;
36
    }
37
38
    /**
39
     * @param Slumberer $slumberer
40
     * @param mixed     $value
41
     *
42
     * @return bool
43
     */
44 11
    public function slumber(Slumberer $slumberer, $value)
45
    {
46 11
        return (bool) $value;
47
    }
48
49
    /**
50
     * @param Awaker $awaker
51
     * @param mixed  $value
52
     *
53
     * @return bool
54
     */
55 10
    public function awake(Awaker $awaker, $value)
56
    {
57 10
        return (bool) $value;
58
    }
59
}
60