Completed
Push — feature/0.7.0 ( 83eb72...2f2cdf )
by Ryuichi
06:35
created

FileReader::read()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
namespace WebStream\IO\Reader;
3
4
use WebStream\IO\FileInputStream;
5
6
/**
7
 * FileReader
8
 * @author Ryuichi TANAKA.
9
 * @since 2016/02/05
10
 * @version 0.7
11
 */
12
class FileReader extends InputStreamReader
13
{
14
    /**
15
     * constructor
16
     * @param mixed $file ファイルオブジェクトまたはファイルパス
17
     */
18
    public function __construct($file)
19
    {
20
        parent::__construct(new FileInputStream($file));
21
    }
22
23
    /**
24
     * ファイルを読み込む
25
     * @return string ファイル内容
26
     */
27
    public function read()
28
    {
29
        $out = "";
30
        while (($data = $this->stream->read(8192)) !== null) {
31
            $out .= $data;
32
        }
33
34
        return $out;
35
    }
36
}
37