PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/google/google/cloud-storage/src/WriteStream.php +14 -14 1.2.121.4.1 View file →
@@ -14,14 +14,14 @@
14 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 15 * See the License for the specific language governing permissions and
16 16 * limitations under the License.
17 17 */
18 -namespace Dudlewebs\WPMCS\Google\Cloud\Storage;
18 +namespace Dudlewebs\WPMCS\GCP\Google\Cloud\Storage;
19 19
20 -use Dudlewebs\WPMCS\Google\Cloud\Core\Upload\AbstractUploader;
21 -use Dudlewebs\WPMCS\GuzzleHttp\Psr7\StreamDecoratorTrait;
22 -use Dudlewebs\WPMCS\GuzzleHttp\Psr7\BufferStream;
23 -use Dudlewebs\WPMCS\Psr\Http\Message\StreamInterface;
20 +use Dudlewebs\WPMCS\GCP\Google\Cloud\Core\Upload\AbstractUploader;
21 +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Psr7\BufferStream;
22 +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Psr7\StreamDecoratorTrait;
23 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\StreamInterface;
24 24 /**
25 25 * A Stream implementation that uploads in chunks to a provided uploader when
26 26 * we reach a certain chunkSize. Upon `close`, we will upload the remaining chunk.
27 27 */
@@ -42,14 +42,14 @@
42 42 * @type int $chunkSize The size of the buffer above which we attempt to
43 43 * upload data
44 44 * }
45 45 */
46 - public function __construct(AbstractUploader $uploader = null, $options = [])
46 + public function __construct(?AbstractUploader $uploader = null, $options = [])
47 47 {
48 48 if ($uploader) {
49 49 $this->setUploader($uploader);
50 50 }
51 - if (array_key_exists('chunkSize', $options)) {
51 + if (\array_key_exists('chunkSize', $options)) {
52 52 $this->chunkSize = $options['chunkSize'];
53 53 }
54 54 $this->stream = new BufferStream($this->chunkSize);
55 55 }
@@ -55,9 +55,9 @@
55 55 }
56 56 /**
57 57 * Close the stream. Uploads any remaining data.
58 58 */
59 - public function close(): void
59 + public function close() : void
60 60 {
61 61 if ($this->uploader && $this->hasWritten) {
62 62 $this->uploader->upload();
63 63 $this->uploader = null;
@@ -69,12 +69,12 @@
69 69 * @param string $data Data to write
70 70 * @return int The number of bytes written
71 71 * @throws \RuntimeException
72 72 */
73 - public function write($data): int
73 + public function write($data) : int
74 74 {
75 75 if (!isset($this->uploader)) {
76 - throw new \RuntimeException("No uploader set.");
76 + throw new \RuntimeException('No uploader set.');
77 77 }
78 78 // Ensure we have a resume uri here because we need to create the streaming
79 79 // upload before we have data (size of 0).
80 80 $this->uploader->getResumeUri();
@@ -81,9 +81,9 @@
81 81 $this->hasWritten = \true;
82 82 if (!$this->stream->write($data)) {
83 83 $this->uploader->upload($this->getChunkedWriteSize());
84 84 }
85 - return strlen($data);
85 + return \strlen($data);
86 86 }
87 87 /**
88 88 * Set the uploader for this class. You may need to set this after initialization
89 89 * if the uploader depends on this stream.
@@ -89,13 +89,13 @@
89 89 * if the uploader depends on this stream.
90 90 *
91 91 * @param AbstractUploader $uploader The new uploader to use.
92 92 */
93 - public function setUploader($uploader): void
93 + public function setUploader($uploader) : void
94 94 {
95 95 $this->uploader = $uploader;
96 96 }
97 - private function getChunkedWriteSize(): int
97 + private function getChunkedWriteSize() : int
98 98 {
99 - return (int) floor($this->getSize() / $this->chunkSize) * $this->chunkSize;
99 + return (int) \floor($this->getSize() / $this->chunkSize) * $this->chunkSize;
100 100 }
101 101 }