Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
EntitySchemaStatus | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
newEdit | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
wrap | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getEntitySchemaId | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare( strict_types = 1 ); |
4 | |
5 | namespace EntitySchema\DataAccess; |
6 | |
7 | use EntitySchema\Domain\Model\EntitySchemaId; |
8 | use MediaWiki\Context\IContextSource; |
9 | use MediaWiki\User\UserIdentity; |
10 | use StatusValue; |
11 | use Wikibase\Repo\TempUserStatus; |
12 | use Wikimedia\Assert\Assert; |
13 | |
14 | /** |
15 | * A Status representing the result of an EntitySchema edit. |
16 | * |
17 | * Note that even an OK status does not necessarily mean that a new edit was made |
18 | * (it might have been a null edit). |
19 | * |
20 | * @license GPL-2.0-or-later |
21 | */ |
22 | class EntitySchemaStatus extends TempUserStatus { |
23 | |
24 | public static function newEdit( |
25 | EntitySchemaId $id, |
26 | ?UserIdentity $savedTempUser, |
27 | IContextSource $context |
28 | ): self { |
29 | return self::newTempUserStatus( [ |
30 | 'id' => $id, |
31 | ], $savedTempUser, $context ); |
32 | } |
33 | |
34 | /** |
35 | * @param StatusValue $sv |
36 | * @return static |
37 | */ |
38 | public static function wrap( $sv ) { |
39 | // This implementation only exists to change the declared return type, |
40 | // from Status to static (i.e. EditEntityStatus); |
41 | // it would become redundant if Ic1a8eccc53 is merged. |
42 | // (Note that the parent *implementation* already returns static, |
43 | // it just isn’t declared as such yet.) |
44 | // @phan-suppress-next-line PhanTypeMismatchReturnSuperType |
45 | return parent::wrap( $sv ); |
46 | } |
47 | |
48 | /** |
49 | * The ID of the EntitySchema touched by this edit. |
50 | * (It may have been created by the edit with a freshly assigned ID.) |
51 | * Only meaningful if the status is {@link self::isOK() OK}. |
52 | */ |
53 | public function getEntitySchemaId(): EntitySchemaId { |
54 | Assert::precondition( $this->isOK(), '$this->isOK()' ); |
55 | return $this->getValue()['id']; |
56 | } |
57 | |
58 | } |