1 | <?php |
||
14 | class StreamReader |
||
15 | { |
||
16 | /** @var bool Flag whether allow_url_fopen is enabled */ |
||
17 | protected $isFopenEnabled = false; |
||
18 | |||
19 | /** @var string Data retrieved from remote */ |
||
20 | public $data = ''; |
||
21 | |||
22 | /** |
||
23 | * Constructor for fastImageSize class |
||
24 | */ |
||
25 | 72 | public function __construct() |
|
30 | |||
31 | /** |
||
32 | * Reset stream reader data |
||
33 | */ |
||
34 | 72 | public function resetData() |
|
38 | |||
39 | /** |
||
40 | * Get force length data |
||
41 | * |
||
42 | * @param int $offset |
||
43 | * @param int $length |
||
44 | * @return bool|string Returned data if long enough, false if not |
||
45 | */ |
||
46 | 47 | protected function getForcedLengthData($offset, $length) |
|
50 | |||
51 | /** |
||
52 | * Get image from specified path/source |
||
53 | * |
||
54 | * @param string $filename Path to image |
||
55 | * @param int $offset Offset at which reading of the image should start |
||
56 | * @param int $length Maximum length that should be read |
||
57 | * @param bool $forceLength True if the length needs to be the specified |
||
58 | * length, false if not. Default: true |
||
59 | * |
||
60 | * @return false|string Image data or false if result was empty |
||
61 | */ |
||
62 | 69 | public function getImage($filename, $offset, $length, $forceLength = true) |
|
78 | |||
79 | /** |
||
80 | * Get image data for specified filename with offset and length |
||
81 | * |
||
82 | * @param string $filename Path to image |
||
83 | * @param int $offset Offset at which reading of the image should start |
||
84 | * @param int $length Maximum length that should be read |
||
85 | */ |
||
86 | 69 | protected function getImageData($filename, $offset, $length) |
|
114 | |||
115 | /** |
||
116 | * Get image data using file get contents if data is empty and |
||
117 | * allow_url_fopen is enabled |
||
118 | * |
||
119 | * @param string $filename Path to image |
||
120 | * @param int $offset Offset at which reading of the image should start |
||
121 | * @param int $length Maximum length that should be read |
||
122 | */ |
||
123 | 69 | protected function getImageDataFopen($filename, $offset, $length) |
|
130 | |||
131 | /** |
||
132 | * Get seekable image data in form of Guzzle stream interface |
||
133 | * |
||
134 | * @param string $filename Filename / URL to get |
||
135 | * @param int $offset Offset for response body |
||
136 | * @return \GuzzleHttp\Stream\StreamInterface|null Stream interface of |
||
137 | * requested image or null if it could not be retrieved |
||
138 | */ |
||
139 | 27 | public function getSeekableImageData($filename, $offset) |
|
154 | } |
||
155 |