Completed
Push — master ( 83ff7f...5810d6 )
by Nicholas
01:05
created

Lookup   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 112
Duplicated Lines 18.75 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 0
dl 21
loc 112
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A USPSLookup::__construct() 0 7 2
A USPSLookup::Address() 0 4 1
A USPSLookup::Tracking() 0 4 1
A USPSLookup::Price() 0 4 1
A USPSLookup::Pickup() 0 4 1

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 Nickcheek\USPSLookup;
4
5
use Nickcheek\USPSLookup\Service\Address;
6
use Nickcheek\USPSLookup\Service\Price;
7
use Nickcheek\USPSLookup\Service\Tracking;
8
use Nickcheek\USPSLookup\Service\Pickup;
9
10
11
class USPSLookup
12
{
13
    protected static $user;
14
    protected static $service = 'http://production.shippingapis.com/ShippingAPI.dll?API=';
15
16
    public function __construct($user = '')
17
    {
18
        self::$user = $user;
19
        if($user == ''){
20
            self::$user = env('USPS');
21
        }
22
    }
23
24
    public function Address()
25
    {
26
        return new Address();
27
    }
28
29
    public function Tracking()
30
    {
31
        return new Tracking();
32
    }
33
34
    public function Price()
35
    {
36
        return new Price();
37
    }
38
39
    public function Pickup()
40
    {
41
        return new Pickup();
42
    }
43
44
}
45