Completed
Pull Request — master (#3)
by Pavel
09:01
created

Router::getCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: batanov.pavel
5
 * Date: 16.02.2016
6
 * Time: 10:25
7
 */
8
9
namespace Bankiru\Api\Rpc\Routing;
10
11
class Router
12
{
13
    /** @var  MethodCollection */
14
    private $collection;
15
16
    /**
17
     * Router constructor.
18
     *
19
     * @param LoaderResolverInterface $resolver
20
     * @param array $resources
21
     * @param MethodCollection|null $collection
22
     */
23 8
    public function __construct(
24
        LoaderResolverInterface $resolver,
25
        array $resources = [],
26
        MethodCollection $collection = null)
27
    {
28 8
        $this->collection = $collection;
29
30 8
        if (null === $this->collection) {
31
            $this->collection = new MethodCollection();
32
        }
33
34 8
        foreach ($resources as $resource) {
35 8
            $this->collection->addCollection($resolver->resolve($resource)->load($resource));
36 8
        }
37 8
    }
38
39
    /**
40
     * @return MethodCollection
41
     */
42 8
    public function getCollection()
43
    {
44 8
        return $this->collection;
45
    }
46
}
47