Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
RendererFactory
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 withTemplate
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\View\Boiler\Error;
6
7use Celemas\Core\Error\Renderer as RendererInterface;
8
9/**
10 * @psalm-import-type DirsInput from \Celemas\Boiler\Engine
11 */
12final class RendererFactory
13{
14    /**
15     * @param DirsInput $dirs
16     * @param array<string, mixed> $context
17     * @param list<class-string> $trusted
18     */
19    public function __construct(
20        private string|array $dirs,
21        private array $context = [],
22        private array $trusted = [],
23        private bool $autoescape = true,
24    ) {}
25
26    /** @param non-empty-string $template */
27    public function withTemplate(string $template): RendererInterface
28    {
29        return new Renderer(
30            $template,
31            $this->dirs,
32            $this->context,
33            $this->trusted,
34            $this->autoescape,
35        );
36    }
37}