Completed
Pull Request — 0.3.x (#4)
by Alexandru-Daniel
05:11 queued 53s
created

UrlSignerExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 42
ccs 0
cts 18
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSignedUrl() 0 4 1
A getFunctions() 0 6 1
A getName() 0 4 1
1
<?php
2
3
namespace Krtv\Bundle\SingleSignOnServiceProviderBundle\Twig\Extension;
4
5
use Symfony\Component\HttpKernel\UriSigner;
6
7
/**
8
 * Class VacancyProposalTrackExtension.
9
 */
10
class UrlSignerExtension extends \Twig_Extension
11
{
12
    /**
13
     * @var UriSigner
14
     */
15
    private $signer;
16
17
    /**
18
     * @param UriSigner $signer
19
     */
20
    public function __construct(UriSigner $signer)
21
    {
22
        $this->signer = $signer;
23
    }
24
25
    /**
26
     * @param string $url
27
     * @return string
28
     */
29
    public function getSignedUrl($url)
30
    {
31
        return $this->signer->sign($url);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function getFunctions()
38
    {
39
        return [
40
            new \Twig_SimpleFunction('sso_url_signer', [$this, 'getSignedUrl']),
41
        ];
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function getName()
48
    {
49
        return 'sso_service_provider.url_signer';
50
    }
51
}
52