5use InvalidArgumentException;
8use Psr\Http\Message\UploadedFileInterface;
24 $this->request = $request;
25 $this->authority = $authority;
33 private function getParamsFromSource(
$source ) {
36 return $this->request->getPathParams();
39 return $this->request->getQueryParams();
42 return $this->request->getPostParams();
45 throw new InvalidArgumentException( __METHOD__ .
": Invalid source '$source'" );
49 public function hasParam( $name, array $options ) {
50 $params = $this->getParamsFromSource( $options[
'source'] );
51 return isset( $params[$name] );
54 public function getValue( $name, $default, array $options ) {
55 $params = $this->getParamsFromSource( $options[
'source'] );
56 return $params[$name] ?? $default;
62 public function hasUpload( $name, array $options ) {
63 if ( $options[
'source'] !==
'post' ) {
70 if ( $options[
'source'] !==
'post' ) {
73 $upload = $this->request->getUploadedFiles()[$name] ??
null;
74 return $upload instanceof UploadedFileInterface ? $upload :
null;
84 return $this->authority->isAllowed(
'apihighlimits' );