DiskResolverCollection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 37
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A get() 0 8 2
A all() 0 4 1
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