Test Failed
Push — master ( 0ee32e...41c938 )
by Dan
07:10
created

RouterFactory::createFastRouter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of the PSR Http Framework.
4
 *
5
 * (c) Dan Smith <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Ds\Router;
11
12
use Ds\Router\Adaptor\FastRouteAdaptor;
13
use Ds\Router\Interfaces\AdaptorInterface;
14
use Ds\Router\Interfaces\RouteCollectionInterface;
15
use Ds\Router\Serializer\SuperClosure;
16
use SuperClosure\Serializer;
17
18
/**
19
 * Class RouterFactory
20
 *
21
 * Factory helper class for creating Routers.
22
 *
23
 * @package Rs\Router
24
 * @author  Dan Smith    <[email protected]>
25
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
26
 * @link    https://github.com/djsmithme/Router
27
 */
28
class RouterFactory
29
{
30
    /**
31
     * @param AdaptorInterface $adaptor
32
     * @param RouteCollectionInterface $collection
33
     * @return Router
34
     */
35
    public static function createRouter(AdaptorInterface $adaptor, RouteCollectionInterface $collection)
36
    {
37
        return new Router($adaptor, $collection);
38
    }
39
40
    /**
41
     * @param array $options
42
     * @return Router
43
     * @throws \Rs\Router\Exceptions\RouterException
44
     */
45
    public static function createFastRouter(array $options = [])
46
    {
47
        return new Router(
48
            new FastRouteAdaptor(
49
                new SuperClosure(
50
                    new Serializer()
51
                ), $options
52
            ),
53
            new RouteCollection()
54
        );
55
    }
56
}
57