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

AbstractLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
loadFile() 0 1 ?
loadFiles() 0 1 ?
A withRouter() 0 6 1
A getRouter() 0 4 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\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
 * @link    https://github.com/djsmithme/Router
24
 */
25
abstract class AbstractLoader implements LoaderInterface
26
{
27
    /**
28
     * @var RouterInterface
29
     */
30
    protected $router;
31
32
    /**
33
     * Load Route File.
34
     *
35
     * @param string $file Route filename.
36
     *
37
     * @return RouteCollectionInterface
38
     * @throws RouterException
39
     */
40
    abstract public function loadFile(string $file);
41
42
    /**
43
     * Load multiple route files.
44
     *
45
     * @param array $files
46
     *
47
     * @return RouterInterface
48
     * @throws RouterException
49
     */
50
    abstract public function loadFiles(array $files);
51
52
    /**
53
     * With Router.
54
     *
55
     * @param RouterInterface $router
56
     * @return LoaderInterface
57
     */
58
    public function withRouter(RouterInterface $router)
59
    {
60
        $new = clone $this;
61
        $new->router = $router;
62
        return $new;
63
    }
64
65
    /**
66
     * Get Router.
67
     * @return RouterInterface
68
     */
69
    public function getRouter()
70
    {
71
        return $this->router;
72
    }
73
}
74