Completed
Push — main ( d84a15...26c7b4 )
by
unknown
04:34
created

FluentRequest::getParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Addwiki\Mediawiki\Api\Client;
4
5
/**
6
 * @since 1.0
7
 *
8
 * @author Addshore
9
 */
10
class FluentRequest implements Request {
11
12
	/**
13
	 * @var array
14
	 */
15
	private $params = [];
16
17
	/**
18
	 * @var array
19
	 */
20
	private $headers = [];
21
22
	/**
23
	 * @since 1.0
24
	 *
25
	 * @return array
26
	 */
27
	public function getParams() {
28
		return $this->params;
29
	}
30
31
	/**
32
	 * @since 1.0
33
	 *
34
	 * @return array
35
	 */
36
	public function getHeaders() {
37
		return $this->headers;
38
	}
39
40
	/**
41
	 * @since 1.0
42
	 *
43
	 * @return static
44
	 */
45
	public static function factory() {
46
		return new static();
47
	}
48
49
	/**
50
	 * @since 1.0
51
	 *
52
	 * @param string $action The action name.
53
	 *
54
	 * @return $this
55
	 */
56
	public function setAction( $action ) {
57
		$this->setParam( 'action', $action );
58
		return $this;
59
	}
60
61
	/**
62
	 * Totally overwrite any previously set params
63
	 *
64
	 * @since 1.0
65
	 *
66
	 * @param array $params New parameters.
67
	 *
68
	 * @return $this
69
	 */
70
	public function setParams( array $params ) {
71
		$this->params = $params;
72
		return $this;
73
	}
74
75
	/**
76
	 * Totally overwrite any previously set params
77
	 *
78
	 * @since 1.0
79
	 *
80
	 * @param array $params Additional parameters.
81
	 *
82
	 * @return $this
83
	 */
84
	public function addParams( array $params ) {
85
		$this->params = array_merge( $this->params, $params );
86
		return $this;
87
	}
88
89
	/**
90
	 * Set a single parameter.
91
	 *
92
	 * @since 1.0
93
	 *
94
	 * @param string $param The parameter name.
95
	 * @param string $value The parameter value.
96
	 *
97
	 * @return $this
98
	 */
99
	public function setParam( $param, $value ) {
100
		$this->params[$param] = $value;
101
		return $this;
102
	}
103
104
	/**
105
	 * Totally overwrite any previously set HTTP headers.
106
	 *
107
	 * @since 1.0
108
	 *
109
	 * @param array $headers New headers.
110
	 *
111
	 * @return $this
112
	 */
113
	public function setHeaders( $headers ) {
114
		$this->headers = $headers;
115
		return $this;
116
	}
117
118
}
119