YAMLResponseParser::extractData()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 7
nc 2
nop 2
crap 2
1
<?php
2
3
4
namespace Beanie\Command\ResponseParser;
5
6
7
use Beanie\Exception\Exception;
8
use Beanie\Server\Server;
9
use Symfony\Component\Yaml\Exception\ParseException;
10
use Symfony\Component\Yaml\Yaml;
11
12
class YAMLResponseParser extends AbstractDataResponseParser
13
{
14
    /**
15
     * @inheritDoc
16
     */
17 2
    protected function extractData($responseLine, Server $server)
18
    {
19 2
        list(, $dataLength) = explode(' ', $responseLine);
20 2
        $rawData = $server->readData($dataLength);
21
22
        try {
23 2
            return Yaml::parse($rawData);
24 1
        } catch (ParseException $exception) {
25 1
            throw Exception::wrap($exception);
26
        }
27
    }
28
}
29