Completed
Pull Request — master (#486)
by Dalibor
02:21
created

AzureBlobStorage::getCreateContainerOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Gaufrette\Adapter;
4
5
use Gaufrette\Adapter;
6
use Gaufrette\Util;
7
use Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface;
8
use MicrosoftAzure\Storage\Blob\Models\Blob;
9
use MicrosoftAzure\Storage\Blob\Models\CreateBlobOptions;
10
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
11
use MicrosoftAzure\Storage\Blob\Models\DeleteContainerOptions;
12
use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions;
13
use MicrosoftAzure\Storage\Common\Exceptions\ServiceException;
14
15
/**
16
 * Microsoft Azure Blob Storage adapter.
17
 *
18
 * @author Luciano Mammino <[email protected]>
19
 * @author Paweł Czyżewski <[email protected]>
20
 */
21
class AzureBlobStorage implements Adapter,
0 ignored issues
show
Coding Style introduced by
The first item in a multi-line implements list must be on the line following the implements keyword
Loading history...
22
                                  MetadataSupporter
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces before interface name; 34 found
Loading history...
23
{
24
    /**
25
     * Error constants.
26
     */
27
    const ERROR_CONTAINER_ALREADY_EXISTS = 'ContainerAlreadyExists';
28
    const ERROR_CONTAINER_NOT_FOUND = 'ContainerNotFound';
29
30
    /**
31
     * @var AzureBlobStorage\BlobProxyFactoryInterface
32
     */
33
    protected $blobProxyFactory;
34
35
    /**
36
     * @var string
37
     */
38
    protected $containerName;
39
40
    /**
41
     * @var bool
42
     */
43
    protected $detectContentType;
44
45
    /**
46
     * @var \MicrosoftAzure\Storage\Blob\Internal\IBlob
47
     */
48
    protected $blobProxy;
49
50
    /**
51
     * @var bool
52
     */
53
    protected $multiContainerMode = false;
54
55
    /**
56
     * @var CreateContainerOptions
57
     */
58
    protected $createContainerOptions;
59
60
    /**
61
     * @param AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
62
     * @param string|null                                $containerName
63
     * @param bool                                       $create
64
     * @param bool                                       $detectContentType
65
     *
66
     * @throws \RuntimeException
67
     */
68
    public function __construct(BlobProxyFactoryInterface $blobProxyFactory, $containerName = null, $create = false, $detectContentType = true)
69
    {
70
        $this->blobProxyFactory = $blobProxyFactory;
71
        $this->containerName = $containerName;
72
        $this->detectContentType = $detectContentType;
73
        if (null === $containerName) {
74
            $this->multiContainerMode = true;
75
        } elseif ($create) {
76
            $this->createContainer($containerName);
77
        }
78
    }
79
80
    /**
81
     * @return CreateContainerOptions
82
     */
83
    public function getCreateContainerOptions()
84
    {
85
        return $this->createContainerOptions;
86
    }
87
88
    /**
89
     * @param CreateContainerOptions $options
90
     */
91
    public function setCreateContainerOptions(CreateContainerOptions $options)
92
    {
93
        $this->createContainerOptions = $options;
94
    }
95
96
    /**
97
     * Creates a new container.
98
     *
99
     * @param string                                                     $containerName
100
     * @param \MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions $options
101
     *
102
     * @throws \RuntimeException if cannot create the container
103
     */
104 View Code Duplication
    public function createContainer($containerName, CreateContainerOptions $options = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
105
    {
106
        $this->init();
107
108
        if (null === $options) {
109
            $options = $this->getCreateContainerOptions();
110
        }
111
112
        try {
113
            $this->blobProxy->createContainer($containerName, $options);
114
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
115
            $errorCode = $this->getErrorCodeFromServiceException($e);
116
117
            if ($errorCode !== self::ERROR_CONTAINER_ALREADY_EXISTS) {
118
                throw new \RuntimeException(sprintf(
119
                    'Failed to create the configured container "%s": %s (%s).',
120
                    $containerName,
121
                    $e->getErrorText(),
122
                    $errorCode
123
                ));
124
            }
125
        }
126
    }
127
128
    /**
129
     * Deletes a container.
130
     *
131
     * @param string                 $containerName
132
     * @param DeleteContainerOptions $options
133
     *
134
     * @throws \RuntimeException if cannot delete the container
135
     */
136 View Code Duplication
    public function deleteContainer($containerName, DeleteContainerOptions $options = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
137
    {
138
        $this->init();
139
140
        try {
141
            $this->blobProxy->deleteContainer($containerName, $options);
142
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
143
            $errorCode = $this->getErrorCodeFromServiceException($e);
144
145
            if ($errorCode !== self::ERROR_CONTAINER_NOT_FOUND) {
146
                throw new \RuntimeException(sprintf(
147
                    'Failed to delete the configured container "%s": %s (%s).',
148
                    $containerName,
149
                    $e->getErrorText(),
150
                    $errorCode
151
                ), $e->getCode());
152
            }
153
        }
154
    }
155
156
    /**
157
     * {@inheritdoc}
158
     * @throws \RuntimeException
159
     */
160 View Code Duplication
    public function read($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
161
    {
162
        $this->init();
163
        list($containerName, $key) = $this->tokenizeKey($key);
164
165
        try {
166
            $blob = $this->blobProxy->getBlob($containerName, $key);
167
168
            return stream_get_contents($blob->getContentStream());
169
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
170
            $this->failIfContainerNotFound($e, sprintf('read key "%s"', $key), $containerName);
171
172
            return false;
173
        }
174
    }
175
176
    /**
177
     * {@inheritdoc}
178
     * @throws \RuntimeException
179
     */
180
    public function write($key, $content)
181
    {
182
        $this->init();
183
        list($containerName, $key) = $this->tokenizeKey($key);
184
185
        $options = new CreateBlobOptions();
186
187
        if ($this->detectContentType) {
188
            $contentType = $this->guessContentType($content);
189
190
            $options->setBlobContentType($contentType);
191
        }
192
193
        try {
194
            $this->createContainer($containerName);
195
196
            $this->blobProxy->createBlockBlob($containerName, $key, $content, $options);
197
198
            if (is_resource($content)) {
199
                return Util\Size::fromResource($content);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return \Gaufrette\Util\S...fromResource($content); (string) is incompatible with the return type declared by the interface Gaufrette\Adapter::write of type integer|boolean.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
200
            }
201
202
            return Util\Size::fromContent($content);
203
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
204
            $this->failIfContainerNotFound($e, sprintf('write content for key "%s"', $key), $containerName);
205
206
            return false;
207
        }
208
    }
209
210
    /**
211
     * {@inheritdoc}
212
     * @throws \RuntimeException
213
     */
214
    public function exists($key)
215
    {
216
        $this->init();
217
        list($containerName, $key) = $this->tokenizeKey($key);
218
219
        $listBlobsOptions = new ListBlobsOptions();
220
        $listBlobsOptions->setPrefix($key);
221
222
        try {
223
            $blobsList = $this->blobProxy->listBlobs($containerName, $listBlobsOptions);
224
225
            foreach ($blobsList->getBlobs() as $blob) {
226
                if ($key === $blob->getName()) {
227
                    return true;
228
                }
229
            }
230
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
231
            $this->failIfContainerNotFound($e, 'check if key exists', $containerName);
232
            $errorCode = $this->getErrorCodeFromServiceException($e);
233
234
            throw new \RuntimeException(sprintf(
235
                'Failed to check if key "%s" exists in container "%s": %s (%s).',
236
                $key,
237
                $containerName,
238
                $e->getErrorText(),
239
                $errorCode
240
            ), $e->getCode());
241
        }
242
243
        return false;
244
    }
245
246
    /**
247
     * {@inheritdoc}
248
     * @throws \RuntimeException
249
     */
250
    public function keys()
251
    {
252
        $this->init();
253
        // list($containerName, $key) = $this->tokenizeKey($key);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
254
255
        try {
256
            $blobList = $this->blobProxy->listBlobs($this->containerName);
257
258
            return array_map(
259
                function (Blob $blob) {
260
                    return $blob->getName();
261
                },
262
                $blobList->getBlobs()
263
            );
264
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
265
            $this->failIfContainerNotFound($e, 'retrieve keys', $this->containerName);
266
            $errorCode = $this->getErrorCodeFromServiceException($e);
267
268
            throw new \RuntimeException(sprintf(
269
                'Failed to list keys for the container "%s": %s (%s).',
270
                $this->containerName,
271
                $e->getErrorText(),
272
                $errorCode
273
            ), $e->getCode());
274
        }
275
    }
276
277
    /**
278
     * {@inheritdoc}
279
     * @throws \RuntimeException
280
     */
281 View Code Duplication
    public function mtime($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
282
    {
283
        $this->init();
284
        list($containerName, $key) = $this->tokenizeKey($key);
285
286
        try {
287
            $properties = $this->blobProxy->getBlobProperties($containerName, $key);
288
289
            return $properties->getProperties()->getLastModified()->getTimestamp();
290
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
291
            $this->failIfContainerNotFound($e, sprintf('read mtime for key "%s"', $key), $containerName);
292
293
            return false;
294
        }
295
    }
296
297
    /**
298
     * {@inheritdoc}
299
     * @throws \RuntimeException
300
     */
301 View Code Duplication
    public function delete($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
302
    {
303
        $this->init();
304
        list($containerName, $key) = $this->tokenizeKey($key);
305
306
        try {
307
            $this->blobProxy->deleteBlob($containerName, $key);
308
309
            return true;
310
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
311
            $this->failIfContainerNotFound($e, sprintf('delete key "%s"', $key), $containerName);
312
313
            return false;
314
        }
315
    }
316
317
    /**
318
     * {@inheritdoc}
319
     * @throws \RuntimeException
320
     */
321
    public function rename($sourceKey, $targetKey)
322
    {
323
        $this->init();
324
325
        list($sourceContainerName, $sourceKey) = $this->tokenizeKey($sourceKey);
326
        list($targetContainerName, $targetKey) = $this->tokenizeKey($targetKey);
327
328
        try {
329
            $this->blobProxy->copyBlob($targetContainerName, $targetKey, $sourceContainerName, $sourceKey);
330
            $this->blobProxy->deleteBlob($sourceContainerName, $sourceKey);
331
332
            return true;
333
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
334
            $this->failIfContainerNotFound($e, sprintf('rename key "%s"', $sourceKey), $sourceContainerName);
335
336
            return false;
337
        }
338
    }
339
340
    /**
341
     * {@inheritdoc}
342
     */
343
    public function isDirectory($key)
344
    {
345
        // Windows Azure Blob Storage does not support directories
346
        return false;
347
    }
348
349
    /**
350
     * {@inheritdoc}
351
     * @throws \RuntimeException
352
     */
353 View Code Duplication
    public function setMetadata($key, $content)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
354
    {
355
        $this->init();
356
        list($containerName, $key) = $this->tokenizeKey($key);
357
358
        try {
359
            $this->blobProxy->setBlobMetadata($containerName, $key, $content);
360
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
361
            $errorCode = $this->getErrorCodeFromServiceException($e);
362
363
            throw new \RuntimeException(sprintf(
364
                'Failed to set metadata for blob "%s" in container "%s": %s (%s).',
365
                $key,
366
                $containerName,
367
                $e->getErrorText(),
368
                $errorCode
369
            ), $e->getCode());
370
        }
371
    }
372
373
    /**
374
     * {@inheritdoc}
375
     * @throws \RuntimeException
376
     */
377 View Code Duplication
    public function getMetadata($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
378
    {
379
        $this->init();
380
        list($containerName, $key) = $this->tokenizeKey($key);
381
382
        try {
383
            $properties = $this->blobProxy->getBlobProperties($containerName, $key);
384
385
            return $properties->getMetadata();
386
        } catch (ServiceException $e) {
0 ignored issues
show
Bug introduced by
The class MicrosoftAzure\Storage\C...ptions\ServiceException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
387
            $errorCode = $this->getErrorCodeFromServiceException($e);
388
389
            throw new \RuntimeException(sprintf(
390
                'Failed to get metadata for blob "%s" in container "%s": %s (%s).',
391
                $key,
392
                $containerName,
393
                $e->getErrorText(),
394
                $errorCode
395
            ), $e->getCode());
396
        }
397
    }
398
399
    /**
400
     * Lazy initialization, automatically called when some method is called after construction.
401
     */
402
    protected function init()
403
    {
404
        if ($this->blobProxy === null) {
405
            $this->blobProxy = $this->blobProxyFactory->create();
406
        }
407
    }
408
409
    /**
410
     * Throws a runtime exception if a give ServiceException derived from a "container not found" error.
411
     *
412
     * @param ServiceException $exception
413
     * @param string           $action
414
     *
415
     * @throws \RuntimeException
416
     */
417
    protected function failIfContainerNotFound(ServiceException $exception, $action, $containerName)
418
    {
419
        $errorCode = $this->getErrorCodeFromServiceException($exception);
420
421
        if ($errorCode === self::ERROR_CONTAINER_NOT_FOUND) {
422
            throw new \RuntimeException(sprintf(
423
                'Failed to %s: container "%s" not found.',
424
                $action,
425
                $containerName
426
            ), $exception->getCode());
427
        }
428
    }
429
430
    /**
431
     * Extracts the error code from a service exception.
432
     *
433
     * @param ServiceException $exception
434
     *
435
     * @return string
436
     */
437
    protected function getErrorCodeFromServiceException(ServiceException $exception)
438
    {
439
        $errorText = $exception->getErrorText();
440
        switch ($errorText) {
441
            case 'The specified container already exists.':
442
                return self::ERROR_CONTAINER_ALREADY_EXISTS;
443
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
444
        }
445
        return $errorText;
446
    }
447
448
    /**
449
     * @param string|resource $content
450
     *
451
     * @return string
452
     */
453 View Code Duplication
    private function guessContentType($content)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
454
    {
455
        $fileInfo = new \finfo(FILEINFO_MIME_TYPE);
456
457
        if (is_resource($content)) {
458
            return $fileInfo->file(stream_get_meta_data($content)['uri']);
459
        }
460
461
        return $fileInfo->buffer($content);
462
    }
463
464
    /**
465
     * @param string $key
466
     *
467
     * @return array
468
     * @throws \InvalidArgumentException
469
     */
470
    private function tokenizeKey($key)
471
    {
472
        $containerName = $this->containerName;
473
        if (true === $this->multiContainerMode) {
474
            if (false === ($index = strpos($key, '/'))) {
475
                throw new \InvalidArgumentException('No /');
476
            }
477
            $containerName = substr($key, 0, $index);
478
            $key = substr($key, $index + 1);
479
        }
480
        return array($containerName, $key);
481
    }
482
}
483