Code Duplication    Length = 35-46 lines in 4 locations

src/Models/Brand.php 1 location

@@ 8-42 (lines=35) @@
5
use FLAIRUK\GoodTillSystem\API;
6
use Illuminate\Support\Facades\Config;
7
8
class Brand extends API {
9
10
    /**
11
     * Create a new Good Till Customer instance.
12
     *
13
     * @param array $user
14
     * @return void
15
     * 
16
     * @source https://apidoc.thegoodtill.com/#api-Brand
17
     */
18
    public function __construct(array $user) {
19
        parent::__construct($user, $this->url);
20
    }
21
22
    /**
23
     * Set Outlet URL
24
     * 
25
     * @param string|null $url
26
     * @return void
27
     */
28
    public function setURL($url = null): void {
29
        $this->url = $url ? $url : Config::get('goodtill.routes.api') . 'outlets';
30
    }
31
    
32
    /**
33
     * Set Product Outlet ID
34
     * 
35
     * @param string $id
36
     * @return object
37
     */
38
    public function setID(string $id): object {
39
        $this->id = $id;
40
        return $this;
41
    }
42
}

src/Models/Outlet.php 1 location

@@ 8-42 (lines=35) @@
5
use FLAIRUK\GoodTillSystem\API;
6
use Illuminate\Support\Facades\Config;
7
8
class Outlet extends API {
9
10
    /**
11
     * Create a new Good Till Outlet instance.
12
     *
13
     * @param array $user
14
     * @return void
15
     * 
16
     * @source https://apidoc.thegoodtill.com/#api-Outlet
17
     */
18
    public function __construct(array $user) {
19
        parent::__construct($user, $this->url);
20
    }
21
22
    /**
23
     * Set Outlet URL
24
     * 
25
     * @param string|null $url
26
     * @return void
27
     */
28
    public function setURL($url = null): void {
29
        $this->url = $url ? $url : Config::get('goodtill.routes.api') . 'outlets';
30
    }
31
    
32
    /**
33
     * Set Product Outlet ID
34
     * 
35
     * @param string $id
36
     * @return object
37
     */
38
    public function setID(string $id): object {
39
        $this->id = $id;
40
        return $this;
41
    }
42
}
43

src/Models/VATRate.php 1 location

@@ 8-42 (lines=35) @@
5
use FLAIRUK\GoodTillSystem\API;
6
use Illuminate\Support\Facades\Config;
7
8
class VATRate extends API {
9
10
    /**
11
     * Create a new Good Till VATRate instance.
12
     *
13
     * @param array $user
14
     * @return void
15
     * 
16
     * @source https://apidoc.thegoodtill.com/#api-VatRate
17
     */
18
    public function __construct(array $user) {
19
        parent::__construct($user, $this->url);
20
    }
21
22
    /**
23
     * Set VATRate URL
24
     * 
25
     * @param string|null $url
26
     * @return void
27
     */
28
    public function setURL($url = null): void {
29
        $this->url = $url ? $url : Config::get('goodtill.routes.api') . 'ajax/vat_rates';
30
    }
31
    
32
    /**
33
     * Set VATRate Outlet ID
34
     * 
35
     * @param string $id
36
     * @return object
37
     */
38
    public function setID(string $id): object {
39
        $this->id = $id;
40
        return $this;
41
    }
42
}

src/Models/Customer.php 1 location

@@ 8-53 (lines=46) @@
5
use FLAIRUK\GoodTillSystem\API;
6
use Illuminate\Support\Facades\Config;
7
8
class Customer extends API {
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
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