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

ImageExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

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