ReadResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 13 4
1
<?php
2
3
namespace seregazhuk\React\Memcached\Protocol\Response;
4
5
use seregazhuk\React\Memcached\Protocol\Parser;
6
7
class ReadResponse extends Response
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function parse()
13
    {
14
        $regExp = '/VALUE [^\s]+ \d+ \d+' . Parser::COMMAND_SEPARATOR . '(.*)' . Parser::COMMAND_SEPARATOR . 'END/';
15
        preg_match($regExp, $this->data, $match);
16
17
        $value = isset($match[1]) ? trim($match[1]) : null;
18
19
        if (null === $value) {
20
            $this->fail();
21
        }
22
23
        // Unserialize non-numeric values
24
        return is_numeric($value) ? $value : unserialize($value);
25
    }
26
}
27