Passed
Push — master ( 6aed0c...b25483 )
by Joachim
03:39
created

PhpTemplatesRenderer::render()   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
declare(strict_types=1);
4
5
namespace Setono\TagBag\Renderer;
6
7
use Setono\PhpTemplates\Engine\EngineInterface;
8
use Setono\TagBag\Tag\PhpTemplatesTagInterface;
9
use Setono\TagBag\Tag\TagInterface;
10
11
final class PhpTemplatesRenderer implements RendererInterface
12
{
13
    /** @var EngineInterface */
14
    private $engine;
15
16 3
    public function __construct(EngineInterface $engine)
17
    {
18 3
        $this->engine = $engine;
19 3
    }
20
21 2
    public function supports(TagInterface $tag): bool
22
    {
23 2
        return $tag instanceof PhpTemplatesTagInterface;
24
    }
25
26
    /**
27
     * @param PhpTemplatesTagInterface|TagInterface $tag
28
     */
29 1
    public function render(TagInterface $tag): string
30
    {
31 1
        return $this->engine->render($tag->getTemplate(), $tag->getContext());
0 ignored issues
show
Bug introduced by
The method getTemplate() does not exist on Setono\TagBag\Tag\TagInterface. It seems like you code against a sub-type of Setono\TagBag\Tag\TagInterface such as Setono\TagBag\Tag\PhpTemplatesTagInterface or Setono\TagBag\Tag\PhpTemplatesTag. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        return $this->engine->render($tag->/** @scrutinizer ignore-call */ getTemplate(), $tag->getContext());
Loading history...
Bug introduced by
The method getContext() does not exist on Setono\TagBag\Tag\TagInterface. It seems like you code against a sub-type of Setono\TagBag\Tag\TagInterface such as Setono\TagBag\Tag\PhpTemplatesTagInterface or Setono\TagBag\Tag\PhpTemplatesTag. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        return $this->engine->render($tag->getTemplate(), $tag->/** @scrutinizer ignore-call */ getContext());
Loading history...
32
    }
33
}
34