Test Setup Failed
Push — master ( 8889c2...0ccb08 )
by Bingo
08:33
created

QrCodeExtension::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace PhpDocxTemplate\Twig\Impl;
4
5
use Twig\Extension\AbstractExtension;
6
use Twig\TwigFunction;
7
use PhpDocxTemplate\Twig\RendererInterface;
8
9
class QrCodeExtension extends AbstractExtension
10
{
11
    private $renderer;
12
13
    /**
14
     * @return mixed
15
     */
16
    public function getFunctions()
17
    {
18
        return [
19
            new TwigFunction('qr_code', [$this, 'qrCode'])
20
        ];
21
    }
22
23
    public function setRenderer(RendererInterface $renderer): void
24
    {
25
        $this->renderer = $renderer;
26
    }
27
28
    public function qrCode(string $url, int $size = 100, int $margin = 10): string
29
    {
30
        return $this->renderer->render($url, $size, $margin);
31
    }
32
}
33