Customer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 46
loc 46
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 3 1
A setURL() 8 8 1
A setID() 4 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 FLAIRUK\GoodTillSystem\Models;
4
5
use FLAIRUK\GoodTillSystem\API;
6
use Illuminate\Support\Facades\Config;
7
8 View Code Duplication
class Customer extends API {
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...
9
10
    /**
11
     * The url attribute.
12
     *
13
     * @var
14
     */
15
    protected $id;
16
17
    /**
18
     * Create a new Good Till Customer instance.
19
     *
20
     * @param array $user
21
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
22
     * 
23
     * @source https://apidoc.thegoodtill.com/#api-Outlet
24
     */
25
    public function __construct(array $user) {
26
        parent::__construct($user, $this->url);
27
    }
28
29
    /**
30
     * Set Outlet URL
31
     * 
32
     * @param string|null $id
33
     * @return void
34
     */
35
    public function setURL($id = null): void { 
36
        $this->url = Config::get('goodtill.routes.api') . 'customers/' . $id ?? $id;
37
        // if (!is_null($id)) {
38
        //     $this->url = Config::get('goodtill.routes.api') . 'customers/' . $this->id ?? $this->id;
39
        // } else {
40
        //     $this->url = $url;
41
        // }
42
    }
43
    /**
44
     * Set Product Outlet ID
45
     * 
46
     * @param string $id
47
     * @return object
48
     */
49
    public function setID(string $id): object {
50
        $this->id = $id;
51
        return $this;
52
    }
53
}
54