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 ( ba89cf...799599 )
by Oleg
02:27
created

Territory::deleteTerritory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 12
loc 12
rs 9.8666
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 View Code Duplication
	public static function addTerritory($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...
71
	{
72
	    $terParams = array();
73
74
        if (isset($params->territory['type'])) $terParams['type'] = $params->territory['type'];
75
        if (isset($params->territory['data'])) $terParams['data'] = $params->territory['data'];
76
        
77
		$response = Route4Me::makeRequst(array(
78
			'url'    => Endpoint::TERRITORY_V4,
79
			'method' => 'ADD',
80
			'query'  => array(
81
				'territory_name'  => isset($params->territory_name) ? $params->territory_name : null,
82
				'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
83
				'territory'       => $terParams
84
			)
85
		));
86
87
		return $response;
88
	}
89
	
90 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...
91
	{
92
		$result = Route4Me::makeRequst(array(
93
			'url'    => Endpoint::TERRITORY_V4,
94
			'method' => 'DELETEARRAY',
95
			'query'  => array(
96
				'territory_id'  => $territory_id
97
			)
98
		));
99
100
		return $result;
101
	}
102
	
103 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...
104
	{
105
	    //var_dump($params); die("");
106
		$response = Route4Me::makeRequst(array(
107
			'url'    => Endpoint::TERRITORY_V4,
108
			'method' => 'PUT',
109
			'query'  => array(
110
                'territory_id'  => isset($params->territory_id) ? $params->territory_id : null
111
            ),
112
            'body'   => array(
113
                'territory_name'   => isset($params->territory_name) ? $params->territory_name : null,
114
                'member_id'        => isset($params->member_id) ? $params->member_id : null,
115
                'territory_color'  => isset($params->territory_color) ? $params->territory_color : null,
116
                'territory'        => isset($params->territory) ? $params->territory : null
117
            ) 
118
119
		));
120
121
		return $response;
122
	}
123
}
124
125