Code Duplication    Length = 7-7 lines in 2 locations

WebStream/IO/FileInputStream.php 1 location

@@ 28-34 (lines=7) @@
25
     */
26
    public function __construct($file)
27
    {
28
        if ($file instanceof File) {
29
            $this->file = $file;
30
        } else if (is_string($file)) {
31
            $this->file = new File($file);
32
        } else {
33
            throw new InvalidArgumentException("Unable to open file: " . $file);
34
        }
35
        $stream = @fopen($this->file->getAbsoluteFilePath(), 'r');
36
        if (!is_resource($stream) || $stream === false) {
37
            throw new IOException("Unable open " . $this->file->getAbsoluteFilePath());

WebStream/IO/FileOutputStream.php 1 location

@@ 28-34 (lines=7) @@
25
     */
26
    public function __construct($file, bool $isAppend = false)
27
    {
28
        if ($file instanceof File) {
29
            $this->file = $file;
30
        } elseif (is_string($file)) {
31
            $this->file = new File($file);
32
        } else {
33
            throw new InvalidArgumentException("Invalid argument type: " . $file);
34
        }
35
36
        $mode = $isAppend ? 'ab' : 'wb';
37
        $stream = @fopen($this->file->getAbsoluteFilePath(), $mode);