File::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
namespace STS\StorageConnect\Drivers\Dropbox;
3
4
use Illuminate\Support\Str;
5
use Kunnu\Dropbox\DropboxFile;
6
7
class File extends DropboxFile
8
{
9
    /**
10
     * File constructor.
11
     *
12
     * @param string $filePath
13
     * @param string $mode
14
     */
15
    public function __construct($filePath, $mode = self::MODE_READ)
16
    {
17
        parent::__construct($filePath, $mode = self::MODE_READ);
18
19
        if(Str::startsWith($filePath, "s3://")) {
20
            $this->setStream($this->getSeekableS3Stream());
21
        }
22
    }
23
24
    /**
25
     * @return \GuzzleHttp\Psr7\Stream
26
     */
27
    protected function getSeekableS3Stream()
28
    {
29
        return \GuzzleHttp\Psr7\stream_for(fopen($this->path, $this->mode, false, stream_context_create([
0 ignored issues
show
Deprecated Code introduced by
The function GuzzleHttp\Psr7\stream_for() has been deprecated with message: stream_for will be removed in guzzlehttp/psr7:2.0. Use Utils::streamFor instead.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
30
            's3' => ['seekable' => true]
31
        ])));
32
    }
33
}