diff options
Diffstat (limited to 'bin/reevotech/vendor/addwiki/mediawiki-api-base/src/SimpleRequest.php')
-rw-r--r-- | bin/reevotech/vendor/addwiki/mediawiki-api-base/src/SimpleRequest.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/bin/reevotech/vendor/addwiki/mediawiki-api-base/src/SimpleRequest.php b/bin/reevotech/vendor/addwiki/mediawiki-api-base/src/SimpleRequest.php new file mode 100644 index 00000000..1e33348d --- /dev/null +++ b/bin/reevotech/vendor/addwiki/mediawiki-api-base/src/SimpleRequest.php @@ -0,0 +1,61 @@ +<?php + +namespace Mediawiki\Api; + +use InvalidArgumentException; + +/** + * Please consider using a FluentRequest object + * + * @since 0.2 + * + * @author Addshore + */ +class SimpleRequest implements Request { + + /** + * @var string + */ + private $action; + + /** + * @var array + */ + private $params; + + /** + * @var array + */ + private $headers; + + /** + * @param string $action The API action. + * @param array $params The parameters for the action. + * @param array $headers Any extra HTTP headers to send. + * + * @throws InvalidArgumentException + */ + public function __construct( $action, array $params = [], array $headers = [] ) { + if ( !is_string( $action ) ) { + throw new InvalidArgumentException( '$action must be string' ); + } + $this->action = $action; + $this->params = $params; + $this->headers = $headers; + } + + /** + * @return string[] + */ + public function getParams() { + return array_merge( [ 'action' => $this->action ], $this->params ); + } + + /** + * @return string[] + */ + public function getHeaders() { + return $this->headers; + } + +} |