forked from radutopala/KnpGaufretteBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FilesystemMap.php
50 lines (44 loc) · 1.03 KB
/
FilesystemMap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Knp\Bundle\GaufretteBundle;
/**
* Holds references to all declared filesystems
* and allows to access them through their name
*/
class FilesystemMap implements \IteratorAggregate
{
/**
* Map of filesystems indexed by their name
*
* @var array
*/
protected $map;
/**
* Instantiates a new filesystem map
*
* @param array $map
*/
public function __construct(array $map)
{
$this->map = $map;
}
/**
* Retrieves a filesystem by its name.
*
* @param string $name name of a filesystem
*
* @return \Gaufrette\Filesystem
*
* @throw \InvalidArgumentException if the filesystem does not exist
*/
public function get($name)
{
if (!isset($this->map[$name])) {
throw new \InvalidArgumentException(sprintf('No filesystem register for name "%s"', $name));
}
return $this->map[$name];
}
public function getIterator()
{
return new \ArrayIterator($this->map);
}
}