Passed
Push — master ( e79061...af4049 )
by Bingo
03:12
created

ImageExtension::setRenderer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 ImageExtension extends AbstractExtension
10
{
11
    private $renderer;
12
13
    /**
14
     * @return mixed
15
     */
16 6
    public function getFunctions()
17
    {
18
        return [
19 6
            new TwigFunction('image', [$this, 'image'])
20
        ];
21
    }
22
23 7
    public function setRenderer(RendererInterface $renderer): void
24
    {
25 7
        $this->renderer = $renderer;
26 7
    }
27
28 1
    public function image(string $path, ?int $width = 100, ?int $height = 100): string
29
    {
30 1
        return $this->renderer->render($path, $width, $height);
31
    }
32
}
33