Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
PageUpdaterStatus
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 newUpdater
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 wrap
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPageUpdater
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare( strict_types = 1 );
4
5namespace EntitySchema\DataAccess;
6
7use MediaWiki\Context\IContextSource;
8use MediaWiki\Storage\PageUpdater;
9use MediaWiki\User\UserIdentity;
10use StatusValue;
11use Wikibase\Repo\TempUserStatus;
12use Wikimedia\Assert\Assert;
13
14/**
15 * A Status representing the result of a {@link MediaWikiPageUpdaterFactory}:
16 * the PageUpdater, and possibly any temporary account that was created.
17 *
18 * @license GPL-2.0-or-later
19 */
20class PageUpdaterStatus extends TempUserStatus {
21
22    public static function newUpdater(
23        PageUpdater $pageUpdater,
24        ?UserIdentity $savedTempUser,
25        IContextSource $context
26    ): self {
27        return self::newTempUserStatus( [
28            'pageUpdater' => $pageUpdater,
29        ], $savedTempUser, $context );
30    }
31
32    /**
33     * @param StatusValue $sv
34     * @return static
35     */
36    public static function wrap( $sv ) {
37        // This implementation only exists to change the declared return type,
38        // from Status to static (i.e. EditEntityStatus);
39        // it would become redundant if Ic1a8eccc53 is merged.
40        // (Note that the parent *implementation* already returns static,
41        // it just isn’t declared as such yet.)
42        // @phan-suppress-next-line PhanTypeMismatchReturnSuperType
43        return parent::wrap( $sv );
44    }
45
46    /**
47     * The newly created PageUpdater.
48     * Only meaningful if the status is {@link self::isOK() OK}.
49     */
50    public function getPageUpdater(): PageUpdater {
51        Assert::precondition( $this->isOK(), '$this->isOK()' );
52        return $this->getValue()['pageUpdater'];
53    }
54
55}