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    /** @var string */
24    private $mString;
25
26    /** @var bool */
27    private $mRead = false;
28
29    /**
30     * @param string $string
31     */
32    public function __construct( $string ) {
33        $this->mString = $string;
34    }
35
36    /**
37     * @return bool
38     */
39    public function atEnd() {
40        return $this->mRead;
41    }
42
43    /**
44     * @return bool|string
45     */
46    public function readChunk() {
47        if ( $this->atEnd() ) {
48            return false;
49        }
50        $this->mRead = true;
51        return $this->mString;
52    }
53
54    /**
55     * @return bool
56     */
57    public function isSeekable() {
58        return true;
59    }
60
61    /**
62     * @param int $offset
63     * @return int
64     */
65    public function seek( int $offset ) {
66        $this->mRead = false;
67        return 0;
68    }
69}
70
71/** @deprecated class alias since 1.46 */
72class_alias( ImportStringSource::class, 'ImportStringSource' );