Completed
Push — 1.x ( d468cb...112be9 )
by Akihito
02:57
created

RequiredParam::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 3
crap 2
1
<?php
2
/**
3
 * This file is part of the BEAR.Resource package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\Resource;
8
9
use BEAR\Resource\Exception\ParameterException;
10
use Ray\Di\InjectorInterface;
11
12
final class RequiredParam implements ParamInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 34
    public function __invoke($varName, array $query, InjectorInterface $injector)
18
    {
19 34
        unset($injector);
20 34
        if (isset($query[$varName])) {
21 29
            return $query[$varName];
22
        }
23
24 5
        throw new ParameterException($varName);
25
    }
26
}
27