Completed
Push — develop ( fd2db3...d57094 )
by Jens
03:05
created

RoutingHelper   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 28
ccs 0
cts 19
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 6 2
A getPath() 0 4 2
A getUrl() 0 4 2
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace JaySDe\HandlebarsBundle\Helper;
7
8
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
9
10
class RoutingHelper implements HelperInterface
11
{
12
    private $generator;
13
    private $type;
14
15
    public function __construct(UrlGeneratorInterface $generator, $type)
16
    {
17
        $this->generator = $generator;
18
        $this->type = $type;
19
    }
20
    
21
    public function handle($context, $options)
22
    {
23
        $options = isset($options['hash']) ? $options['hash'] : [];
24
        $method = 'get' . ucfirst($this->type);
25
        return $this->$method($context, $options);
26
    }
27
28
    private function getPath($name, $parameters = array(), $relative = false)
29
    {
30
        return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
31
    }
32
33
    private function getUrl($name, $parameters = array(), $schemeRelative = false)
34
    {
35
        return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
36
    }
37
}
38