Passed
Push — master ( 17c5f7...cb633b )
by Stefan
04:29 queued 02:00
created

RateTimeInTransit   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 57.14 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 24
loc 42
ccs 0
cts 16
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRateTimeInTransit() 12 12 2
A shopRatesTimeInTransit() 12 12 2

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 Ups;
4
5
use DOMDocument;
6
use DOMElement;
7
use Exception;
8
use SimpleXMLElement;
9
use Ups\Entity\RateRequest;
10
use Ups\Entity\RateResponse;
11
use Ups\Entity\Shipment;
12
13
/**
14
 * RateTimeInTransit API Wrapper.
15
 */
16
class RateTimeInTransit extends Rate
17
{
18
    /**
19
     * @param $rateRequest
20
     *
21
     * @throws Exception
22
     *
23
     * @return RateResponse
24
     */
25 View Code Duplication
    public function getRateTimeInTransit($rateRequest)
0 ignored issues
show
Duplication introduced by
This method 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...
26
    {
27
        if ($rateRequest instanceof Shipment) {
28
            $shipment = $rateRequest;
29
            $rateRequest = new RateRequest();
30
            $rateRequest->setShipment($shipment);
31
        }
32
33
        $this->requestOption = 'Ratetimeintransit';
34
35
        return $this->sendRequest($rateRequest);
36
    }
37
38
    /**
39
     * @param $rateRequest
40
     *
41
     * @throws Exception
42
     *
43
     * @return RateResponse
44
     */
45 View Code Duplication
    public function shopRatesTimeInTransit($rateRequest)
0 ignored issues
show
Duplication introduced by
This method 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...
46
    {
47
        if ($rateRequest instanceof Shipment) {
48
            $shipment = $rateRequest;
49
            $rateRequest = new RateRequest();
50
            $rateRequest->setShipment($shipment);
51
        }
52
53
        $this->requestOption = 'Shoptimeintransit';
54
55
        return $this->sendRequest($rateRequest);
56
    }
57
}
58