Passed
Push — master ( 045368...64d8f0 )
by X
30s
created

StringParser::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
1
<?php
2
/**
3
 * parser for serialized string
4
 */
5
namespace xKerman\Restricted;
6
7
/**
8
 * Parser class for parse serialized PHP stirng
9
 */
10
class StringParser implements ParserInterface
11
{
12
    /**
13
     * parse give `$source` as PHP serialized string
14
     *
15
     * @param Source $source parser input
16
     * @return array parser result
17
     * @throws UnserializeFailedException
18
     */
19 18
    public function parse(Source $source)
20
    {
21 18
        $length = intval($source->match('/\Gs:([+]?[0-9]+):"/'), 10);
22 9
        $result = $source->read($length);
23 9
        $source->consume('";');
24
25 8
        return array($result, $source);
26
    }
27
}
28