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

AbstractRoutingProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 39
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A url() 0 6 1
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