Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PageExists
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Maintenance
20 */
21
22// @codeCoverageIgnoreStart
23require_once __DIR__ . '/Maintenance.php';
24// @codeCoverageIgnoreEnd
25
26use MediaWiki\Maintenance\Maintenance;
27use MediaWiki\Title\Title;
28
29/**
30 * @ingroup Maintenance
31 */
32class PageExists extends Maintenance {
33    public function __construct() {
34        parent::__construct();
35        $this->addDescription( 'Report whether a specific page exists' );
36        $this->addArg( 'title', 'Page title to check whether it exists' );
37    }
38
39    public function execute() {
40        $titleArg = $this->getArg( 0 );
41        $title = Title::newFromText( $titleArg );
42        $pageExists = $title && $title->exists();
43
44        if ( $pageExists ) {
45            $text = "{$title} exists.\n";
46        } else {
47            $text = "{$titleArg} doesn't exist.\n";
48        }
49        $this->output( $text );
50        return $pageExists;
51    }
52}
53
54// @codeCoverageIgnoreStart
55$maintClass = PageExists::class;
56require_once RUN_MAINTENANCE_IF_MAIN;
57// @codeCoverageIgnoreEnd