Request.php
1.24 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace ACP\API;
class Request {
/**
* @var array
*/
protected $args;
/**
* @var string
*/
protected $format;
/**
* @param array $body
*/
public function __construct( array $body = [] ) {
$this->set_body( $body )
->set_format( 'json' )
->set_arg( 'timeout', 15 );
}
/**
* @return array
*/
public function get_body() {
return $this->args['body'];
}
/**
* @param array $value
*
* @return $this
*/
public function set_body( array $value ) {
$this->args['body'] = $value;
return $this;
}
/**
* @return string
*/
public function get_format() {
return $this->format;
}
/**
* @param string $format
*
* @return $this
*/
public function set_format( $format ) {
$this->format = $format;
return $this;
}
public function get_args() {
return $this->args;
}
/**
* @param array $args
*
* @return $this
*/
public function set_args( array $args ) {
$this->args = $args;
return $this;
}
/**
* @param string $key
* @param mixed $value
*
* @return $this
*/
public function set_arg( $key, $value ) {
switch ( $key ) {
case 'body':
$this->set_body( $value );
break;
default:
$this->args[ $key ] = $value;
}
return $this;
}
}