Completed
Pull Request — master (#26)
by X
02:21
created

BooleanParser::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 5
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
1
<?php
2
/**
3
 * parser for PHP serialized boolean
4
 */
5
namespace xKerman\Restricted;
6
7
/**
8
 * Parser for PHP serialized boolean
9
 */
10 View Code Duplication
class BooleanParser implements ParserInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /** @var ParserInterface $parser internal parser for boolean parsing */
13
    private $parser;
14
15
    /**
16
     * constructor
17
     */
18 8
    public function __construct()
19
    {
20 8
        $this->parser = new RegexpSubstringParser('/\Gb:[01];/', 2, 1);
21 8
    }
22
23
    /**
24
     * parse given `$source` as PHP serialized boolean
25
     *
26
     * @param Source $source parser input
27
     * @return array
28
     * @throws UnserializeFailedException
29
     */
30 8
    public function parse(Source $source)
31
    {
32 8
        list($result, $source) = $this->parser->parse($source);
33 2
        return array($result === '1', $source);
34
    }
35
}
36