Passed
Push — master ( f1e2bc...c4cbbf )
by Michiel
05:24
created

OutputStreamWriter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 64.29%

Importance

Changes 0
Metric Value
wmc 5
eloc 7
dl 0
loc 56
ccs 9
cts 14
cp 0.6429
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 3 1
A flush() 0 3 1
A getResource() 0 3 1
A __construct() 0 3 1
A close() 0 3 1
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
namespace Phing\Io;
21
22
/**
23
 * Writer class for OutputStream objects.
24
 *
25
 * Unlike the Java counterpart, this class does not (yet) handle
26
 * character set transformations.  This will be an important function
27
 * of this class with move to supporting PHP6.
28
 *
29
 */
30
class OutputStreamWriter extends Writer
31
{
32
33
    /**
34
     * @var OutputStream
35
     */
36
    protected $outStream;
37
38
    /**
39
     * Construct a new OutputStreamWriter.
40
     *
41
     * @param OutputStream $outStream OutputStream to write to
42
     */
43 39
    public function __construct(OutputStream $outStream)
44
    {
45 39
        $this->outStream = $outStream;
46 39
    }
47
48
    /**
49
     * Close the stream.
50
     *
51
     * @return void
52
     */
53 35
    public function close()
54
    {
55 35
        $this->outStream->close();
56 35
    }
57
58
    /**
59
     * Write char data to stream.
60
     *
61
     * @param string $buf
62
     * @param int $off
63
     * @param int $len
64
     */
65 37
    public function write($buf, $off = null, $len = null)
66
    {
67 37
        $this->outStream->write($buf, $off, $len);
68 37
    }
69
70
    /**
71
     * Flush output to the stream.
72
     */
73
    public function flush()
74
    {
75
        $this->outStream->flush();
76
    }
77
78
    /**
79
     * Gets a string representation of attached stream resource.
80
     *
81
     * @return string String representation of output stream
82
     */
83
    public function getResource()
84
    {
85
        return $this->outStream->__toString();
86
    }
87
}
88