Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
ImportStringSource
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 5
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 atEnd
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 readChunk
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 isSeekable
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 seek
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * MediaWiki page data importer.
4 *
5 * Copyright © 2003,2005 Brooke Vibber <bvibber@wikimedia.org>
6 * https://www.mediawiki.org/
7 *
8 * @license GPL-2.0-or-later
9 * @file
10 * @ingroup SpecialPage
11 */
12
13namespace MediaWiki\Import;
14
15/**
16 * Used for importing XML dumps where the content of the dump is in a string.
17 * This class is inefficient, and should only be used for small dumps.
18 * For larger dumps, ImportStreamSource should be used instead.
19 *
20 * @ingroup SpecialPage
21 */
22class ImportStringSource implements ImportSource {
23    private bool $mRead = false;
24
25    public function __construct(
26        private readonly string $string,
27    ) {
28    }
29
30    /**
31     * @return bool
32     */
33    public function atEnd() {
34        return $this->mRead;
35    }
36
37    /**
38     * @return bool|string
39     */
40    public function readChunk() {
41        if ( $this->atEnd() ) {
42            return false;
43        }
44        $this->mRead = true;
45        return $this->string;
46    }
47
48    /**
49     * @return bool
50     */
51    public function isSeekable() {
52        return true;
53    }
54
55    /**
56     * @param int $offset
57     * @return int
58     */
59    public function seek( int $offset ) {
60        $this->mRead = false;
61        return 0;
62    }
63}
64
65/** @deprecated class alias since 1.46 */
66class_alias( ImportStringSource::class, 'ImportStringSource' );