Passed
Push — master ( 93a267...f5acbf )
by X
32s
created

IntegerParser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 9.4285
c 1
b 0
f 0
1
<?php
2
/**
3
 * parser for PHP serialized integer
4
 */
5
namespace xKerman\Restricted;
6
7
/**
8
 * Parser for PHP serialized integer
9
 */
10
class IntegerParser implements ParserInterface
11
{
12
    /** @var ParserInterface $parser internal parser for integer parsing */
13
    private $parser;
14
15
    /**
16
     * constructor
17
     */
18 17
    public function __construct()
19
    {
20 17
        $this->parser = new TypeConvertParser(
21 17
            new RegexpSubstringParser('/\Gi:[+-]?[0-9]+;/', 2, -1),
22 17
            new IntegerConverter()
23 17
        );
24 17
    }
25
26
    /**
27
     * parse given `$source` as PHP serialized integer
28
     *
29
     * @param Source $source parser input
30
     * @return array
31
     * @throws UnserializeFailedException
32
     */
33 17
    public function parse(Source $source)
34
    {
35 17
        return $this->parser->parse($source);
36
    }
37
}
38