DiskResolverCollection::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
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