Code Duplication    Length = 15-15 lines in 5 locations

src/Gaufrette/Adapter/AzureBlobStorage.php 5 locations

@@ 162-176 (lines=15) @@
159
     * @throws \RuntimeException
160
     * @throws \InvalidArgumentException
161
     */
162
    public function read($key)
163
    {
164
        $this->init();
165
        list($containerName, $key) = $this->tokenizeKey($key);
166
167
        try {
168
            $blob = $this->blobProxy->getBlob($containerName, $key);
169
170
            return stream_get_contents($blob->getContentStream());
171
        } catch (ServiceException $e) {
172
            $this->failIfContainerNotFound($e, sprintf('read key "%s"', $key), $containerName);
173
174
            return false;
175
        }
176
    }
177
178
    /**
179
     * {@inheritdoc}
@@ 300-314 (lines=15) @@
297
     * @throws \RuntimeException
298
     * @throws \InvalidArgumentException
299
     */
300
    public function mtime($key)
301
    {
302
        $this->init();
303
        list($containerName, $key) = $this->tokenizeKey($key);
304
305
        try {
306
            $properties = $this->blobProxy->getBlobProperties($containerName, $key);
307
308
            return $properties->getProperties()->getLastModified()->getTimestamp();
309
        } catch (ServiceException $e) {
310
            $this->failIfContainerNotFound($e, sprintf('read mtime for key "%s"', $key), $containerName);
311
312
            return false;
313
        }
314
    }
315
316
    /**
317
     * {@inheritdoc}
@@ 319-333 (lines=15) @@
316
    /**
317
     * {@inheritdoc}
318
     */
319
    public function size($key)
320
    {
321
        $this->init();
322
        list($containerName, $key) = $this->tokenizeKey($key);
323
324
        try {
325
            $properties = $this->blobProxy->getBlobProperties($containerName, $key);
326
327
            return $properties->getProperties()->getContentLength();
328
        } catch (ServiceException $e) {
329
            $this->failIfContainerNotFound($e, sprintf('read content length for key "%s"', $key), $containerName);
330
331
            return false;
332
        }
333
    }
334
335
    /**
336
     * {@inheritdoc}
@@ 338-352 (lines=15) @@
335
    /**
336
     * {@inheritdoc}
337
     */
338
    public function mimeType($key)
339
    {
340
        $this->init();
341
        list($containerName, $key) = $this->tokenizeKey($key);
342
343
        try {
344
            $properties = $this->blobProxy->getBlobProperties($containerName, $key);
345
346
            return $properties->getProperties()->getContentType();
347
        } catch (ServiceException $e) {
348
            $this->failIfContainerNotFound($e, sprintf('read content mime type for key "%s"', $key), $containerName);
349
350
            return false;
351
        }
352
    }
353
354
    /**
355
     * {@inheritdoc}
@@ 379-393 (lines=15) @@
376
     * @throws \RuntimeException
377
     * @throws \InvalidArgumentException
378
     */
379
    public function delete($key)
380
    {
381
        $this->init();
382
        list($containerName, $key) = $this->tokenizeKey($key);
383
384
        try {
385
            $this->blobProxy->deleteBlob($containerName, $key);
386
387
            return true;
388
        } catch (ServiceException $e) {
389
            $this->failIfContainerNotFound($e, sprintf('delete key "%s"', $key), $containerName);
390
391
            return false;
392
        }
393
    }
394
395
    /**
396
     * {@inheritdoc}