Completed
Push — master ( f27e2e...5dd696 )
by Asmir
10s
created

Fault::createException()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 2
nop 3
crap 3
1
<?php
2
namespace GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages;
3
4
use GoetasWebservices\SoapServices\SoapClient\Envelope\FaultMessageInterface;
5
use GoetasWebservices\SoapServices\SoapClient\Exception\Fault11Exception;
6
use GoetasWebservices\SoapServices\SoapClient\Exception\FaultException;
7
use Psr\Http\Message\RequestInterface;
8
use Psr\Http\Message\ResponseInterface;
9
10
/**
11
 * Class representing Body
12
 */
13 View Code Duplication
class Fault implements FaultMessageInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
16
    /**
17
     * @property \GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages\FaultBody $body
18
     */
19
    private $body = null;
20
21
    /**
22
     * Gets as body
23
     *
24
     * @return \GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages\FaultBody
25
     */
26 4
    public function getBody()
27
    {
28 4
        return $this->body;
29
    }
30
31
    /**
32
     * Sets a new body
33
     *
34
     * @param \GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages\FaultBody $body
35
     * @return self
36
     */
37 2
    public function setBody(\GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages\FaultBody $body)
38
    {
39 2
        $this->body = $body;
40 2
        return $this;
41
    }
42
43
    /**
44
     * @param ResponseInterface $response
45
     * @param RequestInterface $request
46
     * @param \Exception $e
47
     * @return FaultException
48
     */
49 3
    public function createException(ResponseInterface $response, RequestInterface $request, \Exception $e = null)
50
    {
51 3
        if (!$this->getBody() || !$this->getBody()->getFault()) {
52 2
            throw new FaultException($response, $request, $e);
53
        }
54
55 1
        return new Fault11Exception($this->getBody()->getFault(), $response, $request, $e);
56
    }
57
58
59
}
60
61