FaultException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

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
use Fxmlrpc\Serialization\Exception;
6
7
/**
8
 * Thrown when the response is a fault.
9
 *
10
 * @author Márk Sági-Kazár <[email protected]>
11
 */
12
final class FaultException extends \RuntimeException implements Exception
13
{
14
    /**
15
     * @param string $faultString
16
     * @param int    $faultCode
17
     */
18 6
    public function __construct($faultString, $faultCode)
19
    {
20 6
        parent::__construct($faultString, $faultCode);
21 6
    }
22
23
    /**
24
     * Creates a FaultException from XML-RPC response.
25
     *
26
     * @param array $response
27
     *
28
     * @return FaultException
29
     */
30 2
    public static function createFromResponse(array $response)
31
    {
32 2
        $faultString = isset($response['faultString']) ? $response['faultString'] : 'Unknown';
33 2
        $faultCode = isset($response['faultCode']) ? $response['faultCode'] : 0;
34
35 2
        return new self($faultString, $faultCode);
36
    }
37
}
38