Completed
Push — master ( 3691e2...a5d74c )
by Patrick
02:26
created

DiskResolverCollection::release()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 9
rs 9.6666
c 1
b 0
f 1
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Mosaic\Filesystem\Adapters\Flysystem;
4
5
use InvalidArgumentException;
6
7
class DiskResolverCollection
8
{
9
    /**
10
     * @var array
11
     */
12
    private $resolvers = [];
13
14
    /**
15
     * @param          $name
16
     * @param callable $resolver
17
     */
18 12
    public function add(string $name, callable $resolver)
19
    {
20 12
        $this->resolvers[$name] = $resolver;
21 12
    }
22
23
    /**
24
     * @param  string   $name
25
     * @return callable
26
     */
27 9
    public function get(string $name) : callable
28
    {
29 9
        if (!isset($this->resolvers[$name])) {
30 1
            throw new InvalidArgumentException('Disk resolver [' . $name . '] does not exist.');
31
        }
32
33 8
        return $this->resolvers[$name];
34
    }
35
36
    /**
37
     * @return array
38
     */
39 1
    public function all() : array
40
    {
41 1
        return $this->resolvers;
42
    }
43
}
44