Completed
Push — master ( 00e34f...d5f261 )
by Joseph
01:33
created

File   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getSeekableS3Stream() 0 6 1
1
<?php
2
namespace STS\StorageConnect\Drivers\Dropbox;
3
4
use Kunnu\Dropbox\DropboxFile;
5
6
class File extends DropboxFile
7
{
8
    /**
9
     * File constructor.
10
     *
11
     * @param string $filePath
12
     * @param string $mode
13
     */
14
    public function __construct($filePath, $mode = self::MODE_READ)
15
    {
16
        parent::__construct($filePath, $mode = self::MODE_READ);
17
18
        if(starts_with($filePath, "s3://")) {
19
            $this->setStream($this->getSeekableS3Stream());
20
        }
21
    }
22
23
    /**
24
     * @return \GuzzleHttp\Psr7\Stream
25
     */
26
    protected function getSeekableS3Stream()
27
    {
28
        return \GuzzleHttp\Psr7\stream_for(fopen($this->path, $this->mode, false, stream_context_create([
29
            's3' => ['seekable' => true]
30
        ])));
31
    }
32
}