1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19

20
/**
21
 * Convenience class for writing files.
22
 *
23
 * @author  Hans Lellelid <hans@xmpl.org>
24
 * @package phing.system.io
25
 */
26
class BufferedWriter extends Writer
27
{
28

29
    /**
30
     * The size of the buffer in kb.
31
     */
32
    private $bufferSize = 0;
33

34
    /**
35
     * @var Writer The Writer we are buffering output to.
36
     */
37
    private $out;
38

39
    /**
40
     * @param Writer $writer
41
     * @param int $buffsize
42
     */
43 1
    public function __construct(Writer $writer, $buffsize = 8192)
44
    {
45 1
        $this->out = $writer;
46 1
        $this->bufferSize = $buffsize;
47
    }
48

49
    /**
50
     * @param string $buf
51
     * @param int $off
52
     * @param int $len
53
     * @return mixed
54
     */
55 1
    public function write($buf, $off = null, $len = null)
56
    {
57 1
        return $this->out->write($buf, $off, $len);
58
    }
59

60 0
    public function newLine()
61
    {
62 0
        $this->write(PHP_EOL);
63
    }
64

65
    /**
66
     * @return string
67
     */
68 0
    public function getResource()
69
    {
70 0
        return $this->out->getResource();
71
    }
72

73 0
    public function flush()
74
    {
75 0
        $this->out->flush();
76
    }
77

78
    /**
79
     * Close attached stream.
80
     */
81 1
    public function close()
82
    {
83 1
        return $this->out->close();
84
    }
85
}

Read our documentation on viewing source code .

Loading