Passed
Push — master ( 0cb205...76cfc5 )
by Bingo
03:16
created

ImageExtension::image()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
namespace PhpDocxTemplate\Twig\Impl;
4
5
use Twig\Extension\AbstractExtension;
6
use Twig\TwigFunction;
7
use PhpDocxTemplate\Twig\RenderListenerInterface;
8
9
class ImageExtension extends AbstractExtension
10
{
11
    private $listeners = [];
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 addListener(RenderListenerInterface $listener): void
24
    {
25 7
        $this->listeners[] = $listener;
26 7
    }
27
28
    public function image(string $path): string
29
    {
30
        foreach ($this->listeners as $listener) {
31
            $listener->notify($path);
32
        }
33
        return '111';
34
    }
35
}
36