Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
MWBasicRequestAuthorizer
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 isReadAllowed
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isWriteAllowed
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Rest\BasicAccess;
4
5use MediaWiki\Permissions\Authority;
6use MediaWiki\Rest\Handler;
7use MediaWiki\Rest\RequestInterface;
8
9/**
10 * The concrete implementation of basic read/write restrictions in MediaWiki
11 *
12 * @internal
13 */
14class MWBasicRequestAuthorizer extends BasicRequestAuthorizer {
15    /** @var Authority */
16    private $authority;
17
18    public function __construct(
19        RequestInterface $request,
20        Handler $handler,
21        Authority $authority
22    ) {
23        parent::__construct( $request, $handler );
24        $this->authority = $authority;
25    }
26
27    protected function isReadAllowed() {
28        return $this->authority->isAllowed( 'read' );
29    }
30
31    protected function isWriteAllowed() {
32        return $this->authority->isAllowed( 'writeapi' );
33    }
34}