PhpTemplatesRenderer::render()   A
last analyzed

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
use Setono\TagBag\Tag\TemplateTagInterface;
11
12
final class PhpTemplatesRenderer implements RendererInterface
13
{
14
    /** @var EngineInterface */
15
    private $engine;
16
17 3
    public function __construct(EngineInterface $engine)
18
    {
19 3
        $this->engine = $engine;
20 3
    }
21
22 2
    public function supports(TagInterface $tag): bool
23
    {
24 2
        return $tag instanceof PhpTemplatesTagInterface || ($tag instanceof TemplateTagInterface && $tag->getTemplateType() === 'php');
25
    }
26
27
    /**
28
     * @param TemplateTagInterface|TagInterface $tag
29
     */
30 1
    public function render(TagInterface $tag): string
31
    {
32 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\TemplateTagInterface or Setono\TagBag\Tag\TemplateTag. ( Ignorable by Annotation )

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

32
        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\TemplateTagInterface or Setono\TagBag\Tag\TemplateTag. ( Ignorable by Annotation )

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

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