Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
87.50% covered (warning)
87.50%
14 / 16
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
FlaggedRevsScribuntoLuaLibrary
87.50% covered (warning)
87.50%
14 / 16
50.00% covered (danger)
50.00%
1 / 2
6.07
0.00% covered (danger)
0.00%
0 / 1
 register
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 getStabilitySettings
80.00% covered (warning)
80.00%
8 / 10
0.00% covered (danger)
0.00%
0 / 1
5.20
1<?php
2
3use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LibraryBase;
4use MediaWiki\Title\Title;
5
6class FlaggedRevsScribuntoLuaLibrary extends LibraryBase {
7    public function register() {
8        $lib = [
9            'getStabilitySettings' => [ $this, 'getStabilitySettings' ],
10        ];
11
12        return $this->getEngine()->registerInterface(
13            __DIR__ . '/mw.ext.FlaggedRevs.lua', $lib, []
14        );
15    }
16
17    /**
18     * @param string|null $pagename
19     *
20     * @return array
21     */
22    public function getStabilitySettings( $pagename = null ) {
23        $this->checkTypeOptional(
24            'mw.ext.FlaggedRevs.getStabilitySettings', 1, $pagename, 'string', null
25        );
26        $title = $pagename !== null ? Title::newFromText( $pagename ) : $this->getTitle();
27        if ( !$title || !FlaggedRevs::inReviewNamespace( $title ) ) {
28            return [ null ];
29        }
30        $page = FlaggableWikiPage::getTitleInstance( $title );
31        if ( !$page->isDataLoaded() ) {
32            $this->incrementExpensiveFunctionCount();
33        }
34        return [ $page->getStabilitySettings() ];
35    }
36
37}