Passed
Push — up-php7 ( a2fe11...4e1c1e )
by Erik
05:48
created

AbstractRoutingProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Bundle\UrlBundle\Url;
8
9
use Symfony\Component\Routing\RouterInterface;
10
11
/**
12
 * Base class that uses the router for providing urls.
13
 */
14
abstract class AbstractRoutingProvider implements Provider
15
{
16
    /**
17
     * @var RouterInterface
18
     */
19
    protected $router;
20
21
    /**
22
     * Construct the provider.
23
     *
24
     * @param RouterInterface $router
25
     */
26 1
    public function __construct(RouterInterface $router)
27
    {
28 1
        $this->router = $router;
29 1
    }
30
31
32
    /**
33
     * @{inheritDoc}
34
     */
35 1
    public function url($object, array $options = array())
36
    {
37 1
        list($name, $params) = $this->routing($object, $options);
38 1
        return $this->router->generate(
39 1
            $name,
40 1
            $params
41
        );
42
    }
43
    
44
    /**
45
     * Returns the routing for the object. The return value must be an array of two elements: the route name and the
46
     * parameters
47
     *
48
     * @param mixed $object
49
     * @param mixed $options
50
     * @return array
51
     */
52
    abstract public function routing($object, array $options = array());
53
}
54