Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| AuthorizationStatus | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| setUnauthorized | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| isValid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getErrors | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * WikiLambda wrapper for authorization status |
| 4 | * |
| 5 | * @file |
| 6 | * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt |
| 7 | * @license MIT |
| 8 | */ |
| 9 | |
| 10 | namespace MediaWiki\Extension\WikiLambda\Authorization; |
| 11 | |
| 12 | use MediaWiki\Extension\WikiLambda\ZObjects\ZError; |
| 13 | |
| 14 | class AuthorizationStatus { |
| 15 | |
| 16 | /** |
| 17 | * @var bool |
| 18 | */ |
| 19 | private $isValid = true; |
| 20 | |
| 21 | /** |
| 22 | * @var string |
| 23 | */ |
| 24 | private $failedRight; |
| 25 | |
| 26 | /** |
| 27 | * @var ZError|null |
| 28 | */ |
| 29 | private $errors = null; |
| 30 | |
| 31 | /** |
| 32 | * @param string $right |
| 33 | * @param ZError $error |
| 34 | */ |
| 35 | public function setUnauthorized( $right, $error ): void { |
| 36 | $this->isValid = false; |
| 37 | $this->failedRight = $right; |
| 38 | $this->errors = $error; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @return bool |
| 43 | */ |
| 44 | public function isValid(): bool { |
| 45 | return $this->isValid; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @return ZError|null |
| 50 | */ |
| 51 | public function getErrors() { |
| 52 | return $this->errors; |
| 53 | } |
| 54 | } |