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

Territory::updateTerritory()   B

Complexity

Conditions 6
Paths 1

Size

Total Lines 20

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
cc 6
nc 1
nop 1
dl 20
loc 20
rs 8.9777
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 Territory extends Common
9
{
10
	public $territory_id;  // Territory id
11
	public $territory_name; 
12
	public $territory_color;
13
	public $addresses;
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
		if (!isset($params['territory_name'])) {
19
			throw new BadParam('Territory name must be provided');
20
		}
21
		
22
		if (!isset($params['territory_color'])) {
23
			throw new BadParam('Territory color must be provided');
24
		}
25
		
26
		if (!isset($params['territory'])) {
27
			throw new BadParam('Territory must be provided');
28
		}
29
		
30
		$territoryparameters = new Territory();
31
        
32
		foreach($params as $key => $value) {
33
			if (property_exists($territoryparameters, $key)) {
34
				$territoryparameters->{$key} = $value;
35
			}
36
		}
37
		
38
		return $territoryparameters;
39
	}
40
	
41 View Code Duplication
	public static function getTerritory($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...
42
	{
43
		$territory = Route4Me::makeRequst(array(
44
			'url'    => Endpoint::TERRITORY_V4,
45
			'method' => 'GET',
46
			'query'  => array(
47
				'territory_id' => isset($params['territory_id']) ? $params['territory_id'] : null,
48
				'addresses'    => isset($params['addresses']) ? $params['addresses'] : null,
49
			)
50
		));
51
52
		return $territory;
53
	}
54
	
55 View Code Duplication
	public static function getTerritories($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
		$response = Route4Me::makeRequst(array(
58
			'url'    => Endpoint::TERRITORY_V4,
59
			'method' => 'GET',
60
			'query'  => array(
61
				'offset'  => isset($params->offset) ? $params->offset : null,
62
				'limit'   => isset($params->limit) ? $params->limit : null,
63
				'addresses'    => isset($params['addresses']) ? $params['addresses'] : null,
64
			)
65
		));
66
67
		return $response;
68
	}
69
70
	public static function addTerritory($params)
71
	{
72
		$response = Route4Me::makeRequst(array(
73
			'url'    => Endpoint::TERRITORY_V4,
74
			'method' => 'ADD',
75
			'query'  => array(
76
				'territory_name'  => isset($params->territory_name) ? $params->territory_name : null,
77
				'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
78
				'territory'       => isset($params->territory) ? $params->territory : null,
79
			)
80
		));
81
82
		return $response;
83
	}
84
	
85 View Code Duplication
	public function deleteTerritory($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...
86
	{
87
		$result = Route4Me::makeRequst(array(
88
			'url'    => Endpoint::TERRITORY_V4,
89
			'method' => 'DELETEARRAY',
90
			'query'  => array(
91
				'territory_id'  => $territory_id
92
			)
93
		));
94
95
		return $result;
96
	}
97
	
98 View Code Duplication
	public function updateTerritory($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...
99
	{
100
	    //var_dump($params); die("");
101
		$response = Route4Me::makeRequst(array(
102
			'url'    => Endpoint::TERRITORY_V4,
103
			'method' => 'PUT',
104
			'query'  => array(
105
                'territory_id'  => isset($params->territory_id) ? $params->territory_id : null
106
            ),
107
            'body'   => array(
108
                'territory_name'   => isset($params->territory_name) ? $params->territory_name : null,
109
                'member_id'        => isset($params->member_id) ? $params->member_id : null,
110
                'territory_color'  => isset($params->territory_color) ? $params->territory_color : null,
111
                'territory'        => isset($params->territory) ? $params->territory : null
112
            ) 
113
114
		));
115
116
		return $response;
117
	}
118
}
119
120