StringHandler   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 1
eloc 6
c 1
b 1
f 0
dl 0
loc 20
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 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|null $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