Merge "Title: Title::getSubpage should not lose the interwiki prefix"
[lhc/web/wiklou.git] / includes / Rest / BasicAccess / StaticBasicAuthorizer.php
1 <?php
2
3 namespace MediaWiki\Rest\BasicAccess;
4
5 use MediaWiki\Rest\Handler;
6 use MediaWiki\Rest\RequestInterface;
7
8 /**
9 * An authorizer which returns a value from authorize() which is given in the constructor.
10 *
11 * @internal
12 */
13 class StaticBasicAuthorizer implements BasicAuthorizerInterface {
14 private $value;
15
16 /**
17 * @see BasicAuthorizerInterface::authorize()
18 *
19 * @param string|null $value The value returned by authorize(). If the
20 * request is denied, this is the string error code. If the request is
21 * allowed, it is null.
22 */
23 public function __construct( $value = null ) {
24 $this->value = $value;
25 }
26
27 public function authorize( RequestInterface $request, Handler $handler ) {
28 return $this->value;
29 }
30 }