Billing   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 25 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 1
dl 9
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A paid_by() 9 11 3
A method() 0 6 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
 * Created by PhpStorm.
4
 * User: Ocean
5
 * Date: 8/25/2016
6
 * Time: 11:09 PM.
7
 */
8
9
namespace OceanApplications\Postmen\Models;
10
11
class Billing extends Model
12
{
13
    protected $paid_by;
14
    public $method;
15
16
    /**
17
     * @param string $value shipper or third_party
18
     *
19
     * @throws \Exception
20
     *
21
     * @return $this
22
     */
23 View Code Duplication
    public function paid_by($value)
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...
24
    {
25
        if ($value == 'shipper' || $value == 'third_party') {
26
            $this->paid_by = $value;
27
        } else {
28
            $error = 'Paid by must be shipper or third_party';
29
            throw new \Exception($error);
30
        }
31
32
        return $this;
33
    }
34
35
    /**
36
     * @param PaymentMethod $value
37
     *
38
     * @return $this
39
     */
40
    public function method(PaymentMethod $value)
41
    {
42
        $this->method = $value;
43
44
        return $this;
45
    }
46
}
47