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

QrCodeExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 22
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setRenderer() 0 3 1
A qrCode() 0 3 1
A getFunctions() 0 4 1
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