Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
DumpMultiWriter
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 9
272
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 writeOpenStream
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 writeCloseStream
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 writeOpenPage
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 writeClosePage
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 writeRevision
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 closeRenameAndReopen
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 closeAndRename
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 getFilenames
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
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 * @license GPL-2.0-or-later
9 * @file
10 */
11
12/**
13 * @ingroup Dump
14 */
15class DumpMultiWriter {
16    /** @var array */
17    private $sinks;
18    /** @var int */
19    private $count;
20
21    /**
22     * @param array $sinks
23     */
24    public function __construct( $sinks ) {
25        $this->sinks = $sinks;
26        $this->count = count( $sinks );
27    }
28
29    /**
30     * @param string $string
31     */
32    public function writeOpenStream( $string ) {
33        for ( $i = 0; $i < $this->count; $i++ ) {
34            $this->sinks[$i]->writeOpenStream( $string );
35        }
36    }
37
38    /**
39     * @param string $string
40     */
41    public function writeCloseStream( $string ) {
42        for ( $i = 0; $i < $this->count; $i++ ) {
43            $this->sinks[$i]->writeCloseStream( $string );
44        }
45    }
46
47    /**
48     * @param stdClass $page
49     * @param string $string
50     */
51    public function writeOpenPage( $page, $string ) {
52        for ( $i = 0; $i < $this->count; $i++ ) {
53            $this->sinks[$i]->writeOpenPage( $page, $string );
54        }
55    }
56
57    /**
58     * @param string $string
59     */
60    public function writeClosePage( $string ) {
61        for ( $i = 0; $i < $this->count; $i++ ) {
62            $this->sinks[$i]->writeClosePage( $string );
63        }
64    }
65
66    /**
67     * @param stdClass $rev
68     * @param string $string
69     */
70    public function writeRevision( $rev, $string ) {
71        for ( $i = 0; $i < $this->count; $i++ ) {
72            $this->sinks[$i]->writeRevision( $rev, $string );
73        }
74    }
75
76    /**
77     * @param array $newnames
78     */
79    public function closeRenameAndReopen( $newnames ) {
80        $this->closeAndRename( $newnames, true );
81    }
82
83    /**
84     * @param array $newnames
85     * @param bool $open
86     */
87    public function closeAndRename( $newnames, $open = false ) {
88        for ( $i = 0; $i < $this->count; $i++ ) {
89            $this->sinks[$i]->closeAndRename( $newnames[$i], $open );
90        }
91    }
92
93    /**
94     * @return array
95     */
96    public function getFilenames() {
97        $filenames = [];
98        for ( $i = 0; $i < $this->count; $i++ ) {
99            $filenames[] = $this->sinks[$i]->getFilenames();
100        }
101        return $filenames;
102    }
103}