Fault   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 45
loc 45
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBody() 4 4 1
A setBody() 5 5 1
A createException() 7 7 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope12\Messages;
4
5
use GoetasWebservices\SoapServices\SoapClient\Envelope\FaultMessageInterface;
6
use GoetasWebservices\SoapServices\SoapClient\Exception\Fault12Exception;
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\SoapEnvelope12\Messages\FaultBody $body
19
     */
20
    private $body = null;
21
22
    /**
23
     * Gets as body
24
     *
25
     * @return \GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope12\Messages\FaultBody
26
     */
27 5
    public function getBody()
28
    {
29 5
        return $this->body;
30
    }
31
32
    /**
33
     * Sets a new body
34
     *
35
     * @param \GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope12\Messages\FaultBody $body
36
     * @return self
37
     */
38 3
    public function setBody(\GoetasWebservices\SoapServices\SoapClient\Envelope\SoapEnvelope12\Messages\FaultBody $body)
39
    {
40 3
        $this->body = $body;
41 3
        return $this;
42
    }
43
44
    /**
45
     * @param ResponseInterface $response
46
     * @param RequestInterface $request
47
     * @param \Exception $e
48
     * @return FaultException
49
     */
50 4
    public function createException(ResponseInterface $response, RequestInterface $request, \Exception $e = null)
51
    {
52 4
        if (!$this->getBody() || !$this->getBody()->getFault()) {
53 2
            throw new FaultException($response, $request, $e);
54
        }
55 2
        return new Fault12Exception($this->getBody()->getFault(), $response, $request, $e);
56
    }
57
58
}
59
60