Fault::setBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 5
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages;
4
5
use GoetasWebservices\SoapServices\SoapClient\Envelope\FaultMessageInterface;
6
use GoetasWebservices\SoapServices\SoapClient\Exception\Fault11Exception;
7
use GoetasWebservices\SoapServices\SoapClient\Exception\FaultException;
8
use Psr\Http\Message\RequestInterface;
9
use Psr\Http\Message\ResponseInterface;
10
11
/**
12
 * Class representing Body
13
 */
14 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...
15
{
16
17
    /**
18
     * @property \GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages\FaultBody $body
19
     */
20
    private $body = null;
21
22
    /**
23
     * Gets as body
24
     *
25
     * @return \GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages\FaultBody
26
     */
27 4
    public function getBody()
28
    {
29 4
        return $this->body;
30
    }
31
32
    /**
33
     * Sets a new body
34
     *
35
     * @param \GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages\FaultBody $body
36
     * @return self
37
     */
38 2
    public function setBody(\GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope\Messages\FaultBody $body)
39
    {
40 2
        $this->body = $body;
41 2
        return $this;
42
    }
43
44
    /**
45
     * @param ResponseInterface $response
46
     * @param RequestInterface $request
47
     * @param \Exception $e
48
     * @return FaultException
49
     */
50 3
    public function createException(ResponseInterface $response, RequestInterface $request, \Exception $e = null)
51
    {
52 3
        if (!$this->getBody() || !$this->getBody()->getFault()) {
53 2
            throw new FaultException($response, $request, $e);
54
        }
55
56 1
        return new Fault11Exception($this->getBody()->getFault(), $response, $request, $e);
57
    }
58
59
60
}
61
62