AbstractLoader::getRouter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of the DS 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\Loaders;
11
12
use Ds\Router\Exceptions\RouterException;
13
use Ds\Router\Interfaces\LoaderInterface;
14
use Ds\Router\Interfaces\RouteCollectionInterface;
15
use Ds\Router\Interfaces\RouterInterface;
16
17
/**
18
 * Abstract Loader
19
 *
20
 * @package Ds\Router\Loaders
21
 * @author  Dan Smith    <[email protected]>
22
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
23
 */
24
abstract class AbstractLoader implements LoaderInterface
25
{
26
    /**
27
     * @var RouterInterface
28
     */
29
    protected $router;
30
31
    /**
32
     * Load Route File.
33
     *
34
     * @param string $file Route filename.
35
     *
36
     * @return RouteCollectionInterface
37
     * @throws RouterException
38
     */
39
    abstract public function loadFile(string $file);
40
41
    /**
42
     * Load multiple route files.
43
     *
44
     * @param array $files
45
     *
46
     * @return RouterInterface
47
     * @throws RouterException
48
     */
49
    abstract public function loadFiles(array $files);
50
51
    /**
52
     * With Router.
53
     *
54
     * @param RouterInterface $router
55
     * @return LoaderInterface
56
     */
57
    public function withRouter(RouterInterface $router)
58
    {
59
        $new = clone $this;
60
        $new->router = $router;
61
        return $new;
62
    }
63
64
    /**
65
     * Get Router.
66
     * @return RouterInterface
67
     */
68
    public function getRouter()
69
    {
70
        return $this->router;
71
    }
72
}
73