Completed
Push — 3.x ( d7ce4a...622ca0 )
by Paul
12:01
created

Special::__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 1
Bugs 0 Features 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 1
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\Router\Rule;
10
11
use Aura\Router\Route;
12
use Psr\Http\Message\ServerRequestInterface;
13
14
/**
15
 *
16
 * A rule for special matching logic on individual routes.
17
 *
18
 * @package Aura.Router
19
 *
20
 */
21
class Special implements RuleInterface
22
{
23
    /**
24
     *
25
     * Invokes the special matching logic on each individual Route, if any.
26
     *
27
     * @param ServerRequestInterface $request The HTTP request.
28
     *
29
     * @param Route $route The route.
30
     *
31
     * @return bool True on success, false on failure.
32
     *
33
     */
34 4
    public function __invoke(ServerRequestInterface $request, Route $route)
35
    {
36 4
        $special = $route->special;
37 4
        if (! $special) {
38 3
            return true;
39
        }
40
41 1
        return (bool) $special($request, $route);
42
    }
43
}
44