Passed
Push — master ( 54b043...983101 )
by Valentin
05:45
created

XmlResponseParser::_mapYamlList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Pheanstalk;
4
5
use Pheanstalk\Response\ArrayResponse;
6
7
/**
8
 * A response parser for commands that return a subset of XML.
9
 *
10
 * Expected response is 'OK', 'NOT_FOUND' response is also handled.
11
 * Parser expects either a YAML list or dictionary, depending on mode.
12
 *
13
 * @author  Paul Annesley
14
 * @package Pheanstalk
15
 * @license http://www.opensource.org/licenses/mit-license.php
16
 */
17
class XmlResponseParser implements \Pheanstalk\ResponseParser
18
{
19
20
    /**
21 3
     * @param string $responseLine
22
     * @param string $responseData
23 3
     *
24
     * @throws Exception\ServerException
25
     * @return Response\ArrayResponse
26
     */
27
    public function parseResponse($responseLine, $responseData)
28
    {
29 3
        if ($responseLine == Response::RESPONSE_NOT_FOUND) {
30 3
            throw new Exception\ServerException(sprintf(
31 3
                'Server reported %s',
32
                $responseLine
33
            ));
34
        }
35
        unset($responseData['@attributes']);
36
        $content = $responseData;
0 ignored issues
show
Unused Code introduced by
The assignment to $content is dead and can be removed.
Loading history...
37
        return new Response\ArrayResponse('OK', $responseData);
0 ignored issues
show
Bug introduced by
$responseData of type string is incompatible with the type array expected by parameter $data of Pheanstalk\Response\ArrayResponse::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        return new Response\ArrayResponse('OK', /** @scrutinizer ignore-type */ $responseData);
Loading history...
38
    }
39
}
40