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

ImageExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 25
ccs 5
cts 9
cp 0.5556
rs 10
wmc 4

3 Methods

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