Passed
Push — master ( d78e5e...e129d0 )
by Ivan
02:47
created

src/Service/RenderBlock.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\AjaxcomBundle\Service;
6
7
/**
8
 * Class RenderBlock.
9
 *
10
 * @author Ivan Barlog <[email protected]>
11
 */
12
class RenderBlock
13
{
14
    /** @var \Twig_Environment */
0 ignored issues
show
The type Twig_Environment was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
    private $twig;
16
17
    public function __construct(\Twig_Environment $twig)
18
    {
19
        $this->twig = $twig;
20
    }
21
22
    public function render(string $template, string $blockId, array $parameters = []): string
23
    {
24
        $template = $this->twig->load($template);
25
        if (false === $template->hasBlock($blockId)) {
26
            throw new TemplateDoesNotContainBlock();
27
        }
28
29
        $html = $template->renderBlock($blockId, $parameters);
30
        if (empty($html)) {
31
            throw new BlockIsEmpty();
32
        }
33
34
        return $html;
35
    }
36
}
37