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 ( 7f01d7...1527b5 )
by Oleg
02:36
created

Territory::updateTerritory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
	public static function getTerritory($params)
42
	{
43
	    $allQueryFields = array('territory_id', 'addresses');
44
        
45
		$territory = Route4Me::makeRequst(array(
46
			'url'    => Endpoint::TERRITORY_V4,
47
			'method' => 'GET',
48
			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
49
		));
50
51
		return $territory;
52
	}
53
	
54
	public static function getTerritories($params)
55
	{
56
	    $allQueryFields = array('offset', 'limit', 'addresses');
57
        
58
		$response = Route4Me::makeRequst(array(
59
			'url'    => Endpoint::TERRITORY_V4,
60
			'method' => 'GET',
61
			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
62
		));
63
64
		return $response;
65
	}
66
67 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...
68
	{
69
	    $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory');
70
        
71
		$response = Route4Me::makeRequst(array(
72
			'url'    => Endpoint::TERRITORY_V4,
73
			'method' => 'POST',
74
			'body'  => Route4Me::generateRequestParameters($allBodyFields, $params)
75
		));
76
77
		return $response;
78
	}
79
	
80 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...
81
	{
82
		$result = Route4Me::makeRequst(array(
83
			'url'    => Endpoint::TERRITORY_V4,
84
			'method' => 'DELETEARRAY',
85
			'query'  => array(
86
				'territory_id'  => $territory_id
87
			)
88
		));
89
90
		return $result;
91
	}
92
	
93 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...
94
	{
95
	    $allQueryFields = array('territory_id');
96
        $allBodyFields = array('territory_name', 'member_id', 'territory_color', 'territory');
97
        
98
		$response = Route4Me::makeRequst(array(
99
			'url'    => Endpoint::TERRITORY_V4,
100
			'method' => 'PUT',
101
			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
102
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
103
		));
104
105
		return $response;
106
	}
107
}
108