Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <colinodell@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
 
14
namespace League\CommonMark\Renderer;
15
 
16
use League\CommonMark\Node\Node;
17
use League\CommonMark\Util\HtmlElement;
18
 
19
final class HtmlDecorator implements NodeRendererInterface
20
{
21
    private NodeRendererInterface $inner;
22
    private string $tag;
23
    /** @var array<string, string|string[]|bool> */
24
    private array $attributes;
25
    private bool $selfClosing;
26
 
27
    /**
28
     * @param array<string, string|string[]|bool> $attributes
29
     */
30
    public function __construct(NodeRendererInterface $inner, string $tag, array $attributes = [], bool $selfClosing = false)
31
    {
32
        $this->inner       = $inner;
33
        $this->tag         = $tag;
34
        $this->attributes  = $attributes;
35
        $this->selfClosing = $selfClosing;
36
    }
37
 
38
    /**
39
     * {@inheritDoc}
40
     */
41
    public function render(Node $node, ChildNodeRendererInterface $childRenderer)
42
    {
43
        return new HtmlElement($this->tag, $this->attributes, $this->inner->render($node, $childRenderer), $this->selfClosing);
44
    }
45
}