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.
Passed
Push — master ( b2165a...d10d30 )
by Oleg
02:12
created

Address::GetAddressesNotes()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 1
nop 1
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Route4Me;
4
5
use Route4Me\Exception\BadParam;
6
use Route4Me\Route4Me;
7
use GuzzleHttp\Client;
8
use Route4Me\Common;
9
10
class Address extends Common
11
{
12
    static public $apiUrl = '/api.v4/address.php';
13
	static public $apiUrlMove='/actions/route/move_route_destination.php';
14
	static public $apiUrDeparted='/api/route/mark_address_departed.php';
15
	static public $apiUrVisited='/actions/address/update_address_visited.php';
16
17
    public $route_destination_id;
18
    public $alias;
19
    public $member_id;
20
    public $address;
21
    public $is_depot = false;
22
    public $lat;
23
    public $lng;
24
    public $route_id;
25
    public $original_route_id;
26
    public $optimization_problem_id;
27
    public $sequence_no;
28
    public $geocoded;
29
    public $preferred_geocoding;
30
    public $failed_geocoding;
31
    public $geocodings = array();
32
    public $contact_id;
33
    public $is_visited;
34
    public $customer_po;
35
    public $invoice_no;
36
    public $reference_no;
37
    public $order_no;
38
    public $weight;
39
    public $cost;
40
    public $revenue;
41
    public $cube;
42
    public $pieces;
43
    public $email;
44
    public $phone;
45
    public $destination_note_count;
46
    public $drive_time_to_next_destination;
47
    public $distance_to_next_destination;
48
    public $generated_time_window_start;
49
    public $generated_time_window_end;
50
    public $time_window_start;
51
    public $time_window_end;
52
    public $time;
53
	public $notes;
54
    public $timestamp_last_visited;
55
    public $custom_fields = array();
56
    public $manifest = array();
57
58
    public static function fromArray(array $params)
59
    {
60
        /*if (!isset($params['address'])) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
61
            throw new BadParam('address must be provided');
62
        }
63
64
        if (!isset($params['lat'])) {
65
            throw new BadParam('lat must be provided');
66
        }
67
68
        if (!isset($params['lng'])) {
69
            throw new BadParam('lng must be provided');
70
        }*/
71
72
        $address = new Address();
73
        foreach($params as $key => $value) {
74
            if (property_exists($address, $key)) {
75
                $address->{$key} = $value;
76
            }
77
        }
78
79
        return $address;
80
    }
81
82
    public static function getAddress($routeId, $addressId)
83
    {
84
        $address = Route4Me::makeRequst(array(
85
            'url'    => self::$apiUrl,
86
            'method' => 'GET',
87
            'query'  => array(
88
                'route_id'             => $routeId,
89
                'route_destination_id' => $addressId,
90
            )
91
        ));
92
93
        return Address::fromArray($address);
94
    }
95
	
96
	/*Get notes from the specified route destination
97
     * Returns an address object with notes, if an address exists, otherwise - return null.
98
     */
99 View Code Duplication
    public static function GetAddressesNotes($noteParams)
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...
100
    {
101
        $address = Route4Me::makeRequst(array(
102
            'url'    => self::$apiUrl,
103
            'method' => 'GET',
104
            'query'  => array(
105
                'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id']: null, 
106
                'route_destination_id' => isset($noteParams['route_destination_id']) ? $noteParams['route_destination_id'] : null,
107
                'notes' => 1,
108
            )
109
        ));
110
111
        return $address;
112
    }
113
114 View Code Duplication
    public function update()
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...
115
    {
116
        $address = Route4Me::makeRequst(array(
117
            'url'    => self::$apiUrl,
118
            'method' => 'PUT',
119
            'body'   => $this->toArray(),
120
            'query'  => array(
121
                'route_id'             => $this->route_id,
122
                'route_destination_id' => $this->route_destination_id,
123
            ),
124
        ));
125
126
        return Address::fromArray($address);
127
    }
128
	
129 View Code Duplication
	public function markAddress($params, $body)
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...
130
    {
131
        $result = Route4Me::makeRequst(array(
132
            'url'    => self::$apiUrl,
133
            'method' => 'PUT',
134
            'query'  => array(
135
                'route_id'  => isset($params['route_id']) ? $params['route_id']: null, 
136
                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
137
            ),
138
            'body'   => $body
139
        ));
140
141
        return $result;
142
    }
143
	
144 View Code Duplication
	public function markAsDeparted($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...
145
	{
146
		$address = Route4Me::makeRequst(array(
147
            'url'    => self::$apiUrDeparted,
148
            'method' => 'GET',
149
            'query'  => array(
150
                'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
151
                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
152
                'is_departed'   => isset($params['is_departed']) ? $params['is_departed']: null,
153
                'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
154
            ),
155
        ));
156
157
        return $address;
158
	}
159
	
160 View Code Duplication
	public function markAsVisited($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...
161
	{
162
		$address = Route4Me::makeRequst(array(
163
            'url'    => self::$apiUrVisited,
164
            'method' => 'GET',
165
            'query'  => array(
166
                'route_id'   => isset($params['route_id']) ? $params['route_id']: null,
167
                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
168
                'is_visited'   => isset($params['is_visited']) ? $params['is_visited']: null,
169
                'member_id'   => isset($params['member_id']) ? $params['member_id']: null,
170
            ),
171
        ));
172
173
        return $address;
174
	}
175
176 View Code Duplication
    public function delete()
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...
177
    {
178
        $address = Route4Me::makeRequst(array(
179
            'url'    => self::$apiUrl,
180
            'method' => 'DELETE',
181
            'query'  => array(
182
                'route_id'             => $this->route_id,
183
                'route_destination_id' => $this->route_destination_id,
184
            )
185
        ));
186
187
        return (bool)$address['deleted'];
188
    }
189
	
190
	public function MoveDestinationToRoute($params)
191
	{
192
		$result = Route4Me::makeRequst(array(
193
            'url'    => self::$apiUrlMove,
194
            'method' => 'POST',
195
            'query'  => array(
196
                'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null,
197
                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
198
                'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
199
            )
200
        ));
201
202
        return $result;
203
		
204
	}
205
206
    function getAddressId()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
207
    {
208
        return $this->route_destination_id;
209
    }
210
}
211