Completed
Push — master ( b9d832...421ea6 )
by Phil
06:19 queued 04:14
created

ParamStrategy::dispatch()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 3
crap 2
1
<?php
2
3
namespace League\Route\Strategy;
4
5
use League\Route\Http\Exception as HttpException;
6
use League\Route\Route;
7
use RuntimeException;
8
9
class ParamStrategy extends AbstractStrategy implements StrategyInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14 6
    public function dispatch(callable $controller, array $vars, Route $route = null)
15
    {
16 6
        if (method_exists($this->getContainer(), 'call')) {
17 3
            $response = $this->getContainer()->call($controller, $vars);
18
19 3
            return $this->determineResponse($response);
20
        }
21
22 3
        throw new RuntimeException(
23 3
            sprintf(
24 3
                'To use the parameter strategy, the container must implement the (::call) method. (%s) does not.',
25 3
                get_class($this->getContainer())
26 3
            )
27 3
        );
28
    }
29
}
30