Completed
Push — master ( 162e5c...fef8f4 )
by Valentin
23s queued 11s
created

XmlResponseParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
c 0
b 0
f 0
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseResponse() 0 10 2
1
<?php
2
3
namespace Pheanstalk\Parser;
4
5
use Pheanstalk\Exception\ServerException;
6
use Pheanstalk\Response;
7
use Pheanstalk\ResponseParser;
8
9
/**
10
 * A response parser for commands that return a subset of XML.
11
 *
12
 * Expected response is 'OK', 'NOT_FOUND' response is also handled.
13
 * Parser expects either a YAML list or dictionary, depending on mode.
14
 *
15
 * @author  Paul Annesley
16
 * @package Pheanstalk
17
 * @license http://www.opensource.org/licenses/mit-license.php
18
 */
19
class XmlResponseParser implements ResponseParser
20
{
21
22
    /**
23
     * @param string $responseLine
24
     * @param array $responseData
25
     *
26
     * @throws ServerException
27
     * @return array
28
     */
29 7
    public function parseResponse($responseLine, $responseData)
30
    {
31 7
        if ($responseLine == Response::RESPONSE_NOT_FOUND) {
32 1
            throw new ServerException(sprintf(
33 1
                'Server reported %s',
34 1
                $responseLine
35
            ));
36
        }
37 6
        unset($responseData['@attributes']);
38 6
        return $responseData;
39
    }
40
}
41