Completed
Push — master ( a293a3...292fca )
by X
02:23
created

StringHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 1
1
<?php
2
/**
3
 * handler for serialized string
4
 */
5
namespace xKerman\Restricted;
6
7
/**
8
 * Handler class for parse serialized PHP stirng
9
 */
10
class StringHandler implements HandlerInterface
11
{
12
    /** @var integer */
13
    const CLOSE_STRING_LENGTH = 2;
14
15
    /**
16
     * parse give `$source` as PHP serialized string
17
     *
18
     * @param Source $source parser input
19
     * @param string $args   string length
20
     * @return array parser result
21
     * @throws UnserializeFailedException
22
     */
23 10
    public function handle(Source $source, $args)
24
    {
25 10
        $length = intval($args, 10);
26 10
        $result = $source->read($length);
27 10
        $source->consume('";', self::CLOSE_STRING_LENGTH);
28
29 9
        return array($result, $source);
30
    }
31
}
32