Completed
Push — 0.4.x ( 61ba4f )
by Dmitry
15:42 queued 15:37
created

UrlSignerExtension::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
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