Completed
Pull Request — master (#7)
by Márk
02:37
created

FaultException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Fxmlrpc\Serialization\Exception;
4
5
/**
6
 * Thrown when the response is a fault.
7
 *
8
 * @author Márk Sági-Kazár <[email protected]>
9
 */
10
final class FaultException extends ParserException
11
{
12
    /**
13
     * @param string $faultString
14
     * @param int    $faultCode
15
     */
16 7
    public function __construct($faultString, $faultCode)
17
    {
18 7
        parent::__construct($faultString, $faultCode);
19 7
    }
20
21
    /**
22
     * Creates a FaultException from XML-RPC response.
23
     *
24
     * @param array $response
25
     *
26
     * @return FaultException
27
     */
28 2
    public static function createFromResponse(array $response)
29
    {
30 2
        $faultString = isset($response['faultString']) ? $response['faultString'] : 'Unknown';
31 2
        $faultCode = isset($response['faultCode']) ? $response['faultCode'] : 0;
32
33 2
        return new self($faultString, $faultCode);
34
    }
35
}
36