Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
FauxInterwikiLookup
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 5
72
0.00% covered (danger)
0.00%
0 / 1
 isValidInterwiki
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isLocalInterwiki
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 fetch
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getAllPrefixes
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
 invalidateCache
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2namespace JsonConfig;
3
4use Interwiki;
5use MediaWiki\Interwiki\InterwikiLookup;
6
7/**
8 * This class simplifies title parsing using MediaWikiTitleCodec.
9 * Prepend INTERWIKI_PREFIX constant in front of a title, plus ':',
10 * and use it with a custom MediaWikiTitleCodec instance. The original
11 * string will be normalized as an interwiki title, without any custom
12 * logic like namespace or capitalization changes.
13 */
14class FauxInterwikiLookup implements InterwikiLookup {
15
16    /**
17     * This class will only accept this string as a valid interwiki
18     */
19    public const INTERWIKI_PREFIX = 'xyz';
20
21    /**
22     * Check whether an interwiki prefix exists
23     *
24     * @param string $prefix Interwiki prefix to use
25     * @return bool Whether it exists
26     */
27    public function isValidInterwiki( $prefix ) {
28        return (bool)$this->fetch( $prefix );
29    }
30
31    /**
32     * We don't care about local interwikis in this faux lookup
33     * @inheritDoc
34     */
35    public function isLocalInterwiki( $prefix ) {
36        return false;
37    }
38
39    /**
40     * Fetch an Interwiki object
41     *
42     * @param string $prefix Interwiki prefix to use
43     * @return Interwiki|null|bool
44     */
45    public function fetch( $prefix ) {
46        if ( $prefix !== self::INTERWIKI_PREFIX ) {
47            return false;
48        }
49        return new Interwiki( self::INTERWIKI_PREFIX );
50    }
51
52    /**
53     * Returns all interwiki prefixes
54     *
55     * @param string|null $local If set, limits output to local/non-local interwikis
56     * @return array[] List of prefixes
57     */
58    public function getAllPrefixes( $local = null ) {
59        return ( $local === null || $local === false ) ? [ [
60            'iw_prefix' => self::INTERWIKI_PREFIX, 'iw_url' => null, 'iw_local' => false
61        ] ] : [];
62    }
63
64    /**
65     * Purge the in-process and persistent object cache for an interwiki prefix
66     * @param string $prefix
67     */
68    public function invalidateCache( $prefix ) {
69    }
70}