Completed
Push — master ( 2fec61...f9c083 )
by Márk
06:23
created

FaultException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createFromResponse() 0 7 3
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