GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch Editing-Fixing (c4d168)
by Igor
03:30
created

AvoidanceZone::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Route4Me;
3
4
use Route4Me\Common;
5
use Route4Me\Exception\BadParam;
6
use Route4Me\Enum\Endpoint;
7
8
class AvoidanceZone extends Common
9
{
10
    public $territory_id;  // Avoidance zone id
11
    public $territory_name; 
12
    public $territory_color;
13
    public $orders;
14
    public $member_id;
15
    public $territory; // Territory parameters
16
    
17 View Code Duplication
    public static function fromArray(array $params) 
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...
18
    {
19
        if (!isset($params['territory_name'])) {
20
            throw new BadParam('Territory name must be provided');
21
        }
22
        
23
        if (!isset($params['territory_color'])) {
24
            throw new BadParam('Territory color must be provided');
25
        }
26
        
27
        if (!isset($params['territory'])) {
28
            throw new BadParam('Territory must be provided');
29
        }
30
        
31
        $avoidanceZoneParameters = new AvoidanceZone();
32
        
33
        foreach($params as $key => $value) {
34
            if (property_exists($avoidanceZoneParameters, $key)) {
35
                $avoidanceZoneParameters->{$key} = $value;
36
            }
37
        }
38
        
39
        return $avoidanceZoneParameters;
40
    }
41
    
42
    public static function getAvoidanceZone($territory_id)
43
    {
44
        $avoidanceZone = Route4Me::makeRequst(array(
45
            'url'    => Endpoint::AVOIDANCE_ZONE,
46
            'method' => 'GET',
47
            'query'  => array(
48
                'territory_id' => $territory_id
49
            )
50
        ));
51
52
        return $avoidanceZone;
53
    }
54
    
55 View Code Duplication
    public static function getAvoidanceZones($params)
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...
56
    {
57
        $avoidanceZones = Route4Me::makeRequst(array(
58
            'url'    => Endpoint::AVOIDANCE_ZONE,
59
            'method' => 'GET',
60
            'query'  => array(
61
                'offset'  => isset($params->offset) ? $params->offset : null,
62
                'limit'   => isset($params->limit) ? $params->limit : null,
63
            )
64
        ));
65
66
        return $avoidanceZones;
67
    }
68
69
    public static function addAvoidanceZone($params)
70
    {
71
        $abContacts = Route4Me::makeRequst(array(
72
            'url'    => Endpoint::AVOIDANCE_ZONE,
73
            'method' => 'ADD',
74
            'query'  => array(
75
                'territory_name'  => isset($params->territory_name) ? $params->territory_name : null,
76
                'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
77
                'territory'       => isset($params->territory) ? $params->territory : null,
78
            )
79
        ));
80
81
        return $abContacts;
82
    }
83
    
84 View Code Duplication
    public function deleteAvoidanceZone($territory_id)
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...
85
    {
86
        $result = Route4Me::makeRequst(array(
87
            'url'    => Endpoint::AVOIDANCE_ZONE,
88
            'method' => 'DELETEARRAY',
89
            'query'  => array(
90
                'territory_id' => $territory_id
91
            )
92
        ));
93
94
        return $result;
95
    }
96
    
97
    public function updateAvoidanceZone($params)
98
    {
99
        $avoidanceZone = Route4Me::makeRequst(array(
100
            'url'    => Endpoint::AVOIDANCE_ZONE,
101
            'method' => 'PUT',
102
            'body'   => $params,
103
104
        ));
105
106
        return $avoidanceZone;
107
    }
108
}
109