Passed
Pull Request — master (#9)
by Pavel
11:27
created

CollectionMatcher::match()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Bankiru\Api\Rpc\Routing;
4
5
use Bankiru\Api\Rpc\Routing\Exception\MethodNotFoundException;
6
7
final class CollectionMatcher implements MethodMatcher
8
{
9
    /**
10
     * @var MethodCollection
11
     */
12
    private $collection;
13
14
    /**
15
     * CollectionMatcher constructor.
16
     *
17
     * @param MethodCollection $collection
18
     */
19
    public function __construct(MethodCollection $collection)
20
    {
21
        $this->collection = $collection;
22
    }
23
24
    /** {@inheritdoc} */
25
    public function match($method)
26
    {
27
        if (!$this->collection->has($method)) {
28
            throw new MethodNotFoundException($method);
29
        }
30
31
        return AttributesHelper::getAttributes($this->collection->get($method), $method);
32
    }
33
}
34