Test Failed
Push — master ( d4b731...813def )
by Dan
08:06
created

AbstractAdaptor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 41.67%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 63
ccs 5
cts 12
cp 0.4167
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getOptions() 0 4 1
A getOption() 0 7 2
match() 0 1 ?
getCachedRoutes() 0 1 ?
isCached() 0 1 ?
A withOptions() 0 4 1
1
<?php
2
/**
3
 * This file is part of the RS 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\Adaptor;
11
12
use Ds\Router\Interfaces\AdaptorInterface;
13
use Ds\Router\Interfaces\RouteCollectionInterface;
14
use Ds\Router\Interfaces\SerializerInterface;
15
16
/**
17
 * Class AbstractAdaptor
18
 *
19
 * @package Rs\Router\Adaptor
20
 * @author  Dan Smith    <[email protected]>
21
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
22
 * @link    https://red-sqr.co.uk/Framework/Router/wikis/
23
 */
24
abstract class AbstractAdaptor implements AdaptorInterface
25
{
26
    /**
27
     * @var SerializerInterface
28
     */
29
    public $serializer;
30
    /**
31
     * @var array
32
     */
33
    protected $options = [];
34
35
    /**
36
     * Adaptor constructor.
37
     * @param SerializerInterface $serializer
38
     */
39 11
    public function __construct(SerializerInterface $serializer)
40
    {
41 11
        $this->serializer = $serializer;
42 11
    }
43
44
45
    /**
46
     * @inheritdoc
47
     */
48 1
    public function getOptions()
49
    {
50 1
        return $this->options;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public function getOption($key)
57
    {
58
        if (isset($this->options[$key])) {
59
            return $this->options[$key];
60
        }
61
        return null;
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function withOptions(array $options = [])
68
    {
69
        $this->options = $options;
70
    }
71
72
    /**
73
     * @inheritdoc
74
     */
75
    abstract public function match(RouteCollectionInterface $routes, $method, $requestTarget);
76
77
    /**
78
     * @inheritdoc
79
     */
80
    abstract public function getCachedRoutes($context = '');
81
82
    /**
83
     * @inheritdoc
84
     */
85
    abstract public function isCached();
86
}
87