Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
DumpMultiWriter | |
0.00% |
0 / 19 |
|
0.00% |
0 / 9 |
272 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
writeOpenStream | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
writeCloseStream | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
writeOpenPage | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
writeClosePage | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
writeRevision | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
closeRenameAndReopen | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
closeAndRename | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
getFilenames | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * Base class for output stream; prints to stdout or buffer or wherever. |
4 | * |
5 | * Copyright © 2003, 2005, 2006 Brooke Vibber <bvibber@wikimedia.org> |
6 | * https://www.mediawiki.org/ |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU General Public License along |
19 | * with this program; if not, write to the Free Software Foundation, Inc., |
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21 | * http://www.gnu.org/copyleft/gpl.html |
22 | * |
23 | * @file |
24 | */ |
25 | |
26 | /** |
27 | * @ingroup Dump |
28 | */ |
29 | class DumpMultiWriter { |
30 | /** @var array */ |
31 | private $sinks; |
32 | /** @var int */ |
33 | private $count; |
34 | |
35 | /** |
36 | * @param array $sinks |
37 | */ |
38 | public function __construct( $sinks ) { |
39 | $this->sinks = $sinks; |
40 | $this->count = count( $sinks ); |
41 | } |
42 | |
43 | /** |
44 | * @param string $string |
45 | */ |
46 | public function writeOpenStream( $string ) { |
47 | for ( $i = 0; $i < $this->count; $i++ ) { |
48 | $this->sinks[$i]->writeOpenStream( $string ); |
49 | } |
50 | } |
51 | |
52 | /** |
53 | * @param string $string |
54 | */ |
55 | public function writeCloseStream( $string ) { |
56 | for ( $i = 0; $i < $this->count; $i++ ) { |
57 | $this->sinks[$i]->writeCloseStream( $string ); |
58 | } |
59 | } |
60 | |
61 | /** |
62 | * @param stdClass $page |
63 | * @param string $string |
64 | */ |
65 | public function writeOpenPage( $page, $string ) { |
66 | for ( $i = 0; $i < $this->count; $i++ ) { |
67 | $this->sinks[$i]->writeOpenPage( $page, $string ); |
68 | } |
69 | } |
70 | |
71 | /** |
72 | * @param string $string |
73 | */ |
74 | public function writeClosePage( $string ) { |
75 | for ( $i = 0; $i < $this->count; $i++ ) { |
76 | $this->sinks[$i]->writeClosePage( $string ); |
77 | } |
78 | } |
79 | |
80 | /** |
81 | * @param stdClass $rev |
82 | * @param string $string |
83 | */ |
84 | public function writeRevision( $rev, $string ) { |
85 | for ( $i = 0; $i < $this->count; $i++ ) { |
86 | $this->sinks[$i]->writeRevision( $rev, $string ); |
87 | } |
88 | } |
89 | |
90 | /** |
91 | * @param array $newnames |
92 | */ |
93 | public function closeRenameAndReopen( $newnames ) { |
94 | $this->closeAndRename( $newnames, true ); |
95 | } |
96 | |
97 | /** |
98 | * @param array $newnames |
99 | * @param bool $open |
100 | */ |
101 | public function closeAndRename( $newnames, $open = false ) { |
102 | for ( $i = 0; $i < $this->count; $i++ ) { |
103 | $this->sinks[$i]->closeAndRename( $newnames[$i], $open ); |
104 | } |
105 | } |
106 | |
107 | /** |
108 | * @return array |
109 | */ |
110 | public function getFilenames() { |
111 | $filenames = []; |
112 | for ( $i = 0; $i < $this->count; $i++ ) { |
113 | $filenames[] = $this->sinks[$i]->getFilenames(); |
114 | } |
115 | return $filenames; |
116 | } |
117 | } |