Issues (20)

Reader/FileReader.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace WebStream\IO\Reader;
4
5
use WebStream\Exception\Extend\InvalidArgumentException;
0 ignored issues
show
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...
6
use WebStream\Exception\Extend\IOException;
0 ignored issues
show
The type WebStream\Exception\Extend\IOException 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
use WebStream\IO\FileInputStream;
8
9
/**
10
 * FileReader
11
 * @author Ryuichi TANAKA.
12
 * @since 2016/02/05
13
 * @version 0.7
14
 */
15
class FileReader extends InputStreamReader
16
{
17
    /**
18
     * @var int バッファリングサイズ
19
     */
20
    private int $bufferSize;
21
22
    /**
23
     * constructor
24
     * @param mixed $file ファイルオブジェクトまたはファイルパス
25
     * @param int $bufferSize バッファリングサイズ
26
     * @throws InvalidArgumentException
27
     * @throws IOException
28
     */
29 11
    public function __construct($file, int $bufferSize = 8192)
30
    {
31 11
        parent::__construct(new FileInputStream($file));
32 11
        $this->bufferSize = $bufferSize;
33
    }
34
35
    /**
36
     * ファイルを読み込む
37
     * @return string ファイル内容
38
     * @throws IOException
39
     */
40 11
    public function read()
41
    {
42 11
        $out = "";
43 11
        while (($data = $this->stream->read($this->bufferSize)) !== null) {
44 11
            $out .= $data;
45
        }
46
47 11
        return $out;
48
    }
49
}
50