-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathClient.php
executable file
·66 lines (50 loc) · 1.66 KB
/
Client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace ServerPilot;
class Client
{
/** Location for overloaded data. */
private $data = array();
public function __construct($client_id, $api_key, $transport = null)
{
if(is_null($transport)) {
$transport = self::getTransport('Curl', $client_id, $api_key);
}
$this->transport = $transport;
}
public function __set($name, $value)
{
$this->data[$name] = $value;
}
public function __get($name)
{
if (array_key_exists($name, $this->data)) {
return $this->data[$name];
}
$trace = debug_backtrace();
trigger_error(
'Undefined property via __get(): ' . $name .
' in ' . $trace[0]['file'] .
' on line ' . $trace[0]['line'],
E_USER_NOTICE);
return null;
}
public function __call($name, $arguments)
{
require_once __DIR__ . '/Resources/Resource.php';
$arguments = array_merge(array(
$name,
$this->transport
), $arguments);
return forward_static_call_array(array('ServerPilot\Client', 'getResource'), $arguments);
}
static function getTransport($name, $client_id, $api_key) {
require_once __DIR__ . '/Transports/Transport.php';
$arguments = func_get_args();
return forward_static_call_array(array('ServerPilot\Transports\Transport', 'getInstance'), $arguments);
}
static function getResource($name, $transport) {
require_once __DIR__ . '/Resources/Resource.php';
$arguments = func_get_args();
return forward_static_call_array(array('ServerPilot\Resources\Resource', 'getInstance'), $arguments);
}
}