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

IntegerParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A parse() 0 4 1
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