Passed
Push — master ( 35a69c...54bf96 )
by Ryuichi
01:46
created

OutputStreamWriter::flush()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace WebStream\IO\Writer;
4
5
use WebStream\IO\OutputStream;
6
use WebStream\Exception\Extend\InvalidArgumentException;
0 ignored issues
show
Bug introduced by
The type WebStream\Exception\Exte...nvalidArgumentException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * OutputStreamWriter
10
 * @author Ryuichi TANAKA.
11
 * @since 2016/02/24
12
 * @version 0.7
13
 */
14
class OutputStreamWriter
15
{
16
    /**
17
     * @var OutputStream 出力ストリーム
18
     */
19
    protected $stream;
20
21
    /**
22
     * constructor
23
     * @param OutputStream $stream 出力ストリーム
24
     */
25 15
    public function __construct(OutputStream $stream)
26
    {
27 15
        $this->stream = $stream;
28
    }
29
30
    /**
31
     * destructor
32
     */
33 17
    public function __destruct()
34
    {
35 17
        $this->close();
36
    }
37
38
    /**
39
     * バッファリングしているすべての出力バイトを書き出し、出力ストリームを閉じる
40
     * @throws WebStream\Exception\Extend\IOException
41
     */
42 15
    public function close()
43
    {
44 15
        $this->stream->close();
45
    }
46
47
    /**
48
     * 出力ストリームに書き出す
49
     * @param mixed $buf 出力データ
50
     * @throws WebStream\Exception\Extend\IOException
51
     */
52 12
    public function write($buf)
53
    {
54 12
        $args = func_get_args();
55 12
        $off = array_key_exists(1, $args) ? $args[1] : null;
56 12
        $len = array_key_exists(2, $args) ? $args[2] : null;
57
58 12
        $this->stream->write($buf, $off, $len);
59
    }
60
61
    /**
62
     * バッファリングしているすべての出力バイトを出力ストリームを閉じずに強制的に書き出す
63
     * writeを実行した時点では書き出されておらず、flushした時点ですべて書き出す
64
     * @throws WebStream\Exception\Extend\IOException
65
     */
66 12
    public function flush()
67
    {
68 12
        $this->stream->flush();
69
    }
70
71
    /**
72
     * 改行を書き出す
73
     * @throws WebStream\Exception\Extend\IOException
74
     */
75
    public function newLine()
76
    {
77
        $this->stream->write(PHP_EOL);
78
    }
79
}
80