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
Push — master ( b18c19...dec958 )
by Jacky
04:52
created

API::getPlayerStatement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Asylamba\Classes\Worker;
4
5
use Asylamba\Classes\Library\Security;
6
7
class API {
8
	# API user
9
	/** @var string **/
10
	private $path;
11
	/** @var string **/
12
	private $serverId;
13
	/** @var string **/
14
	private $key;
15
16
	public $query;
17
	public $data;
18
19
	const TEMPLATE_INACTIVE_PLAYER = 51;
20
	const TEMPLATE_SPONSORSHIP = 52;
21
22
	/**
23
	 * @param Security $security
24
	 * @param string $serverId
25
	 * @param string $apiKey
26
	 * @param string $getOutRoot
27
	 */
28
	public function __construct(Security $security, $serverId, $apiKey, $getOutRoot) {
29
		$this->path = $getOutRoot;
30
		$this->serverId = $serverId;
31
		$this->key  = $apiKey;
32
		$this->security = $security;
0 ignored issues
show
Bug introduced by
The property security does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
33
	}
34
35
	private function query($api, $args) {
36
		$targ = '';
37
		$ch  = curl_init();
38
39
		foreach ($args as $k => $v) {
40
			$targ .= $k . '-' . $v . '/';
41
		}
42
43
		$this->query = $this->path . 'api/s-' . $this->serverId . '/a-' . $this->security->crypt('a-' . $api . '/' . $targ, $this->key);
44
		
45
		curl_setopt($ch, CURLOPT_URL, $this->query);
46
		curl_setopt($ch, CURLOPT_RETURNTRANSFER , TRUE);
0 ignored issues
show
Coding Style introduced by
Space found before comma in function call
Loading history...
47
		$answer = curl_exec($ch);
48
		curl_close($ch);
49
		
50
		if ($answer !== FALSE) {
51
			$this->data = unserialize($answer);
52
			return TRUE;
53
		} else {
54
			return FALSE;
55
		}
56
	}
57
58
	public function userExist($bindkey) {
59
		if ($this->query('userexist', array('bindkey' => $bindkey))) {
60
			if ($this->data['statement'] == 'success') {
61
				return TRUE;
62
			} else {
63
				return FALSE;
64
			}
65
		} else {
66
			return FALSE;
67
		}
68
	}
69
70
	public function confirmInscription($bindkey) {
71
		if ($this->query('confirminscription', array('bindkey' => $bindkey, 'serverid' => $this->serverId))) {
72
			if ($this->data['statement'] == 'success') {
73
				return TRUE;
74
			} else {
75
				return FALSE;
76
			}
77
		} else {
78
			return FALSE;
79
		}
80
	}
81
82
	public function confirmConnection($bindkey) {
83
		if ($this->query('confirmconnection', array('bindkey' => $bindkey, 'serverid' => $this->serverId))) {
84
			if ($this->data['statement'] == 'success') {
85
				return TRUE;
86
			} else {
87
				return FALSE;
88
			}
89
		} else {
90
			return FALSE;
91
		}
92
	}
93
94
	public function playerIsDead($bindkey, $serverId) {
95
		if ($this->query('playerisdead', array('bindkey' => $bindkey, 'serverid' => $serverId))) {
96
			if ($this->data['statement'] == 'success') {
97
				return TRUE;
98
			} else {
99
				return FALSE;
100
			}
101
		} else {
102
			return FALSE;
103
		}
104
	}
105
106
	public function sendMail($bindkey, $template) {
107
		if ($this->query('sendmail', array('bindkey' => $bindkey, 'serverid' => $this->serverId, 'template' => $template))) {
108
			if ($this->data['statement'] == 'success') {
109
				return TRUE;
110
			} else {
111
				return FALSE;
112
			}
113
		} else {
114
			return FALSE;
115
		}
116
	}
117
118
	public function sendMail2($email, $serverId, $template, $playerId) {
119
		if ($this->query('sendmail2', array('email' => $email, 'serverid' => $serverId, 'template' => $template, 'playerid' => $playerId))) {
120
			if ($this->data['statement'] == 'success') {
121
				return TRUE;
122
			} else {
123
				return FALSE;
124
			}
125
		} else {
126
			return FALSE;
127
		}
128
	}
129
130
	public function abandonServer($bindkey) {
131
		if ($this->query('abandonserver', array('bindkey' => $bindkey, 'serverid' => $this->serverId))) {
132
			if ($this->data['statement'] == 'success') {
133
				return TRUE;
134
			} else {
135
				return FALSE;
136
			}
137
		} else {
138
			return FALSE;
139
		}
140
	}
141
}
142