Completed
Pull Request — 1.2 (#12)
by David
01:10
created

RendererFacade   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A render() 0 4 1
1
<?php
2
3
4
namespace Mouf\Html\Renderer;
5
6
/**
7
 * A facade for the default renderer.
8
 * Used by the `Renderable` trait.
9
 * Initialized by the InitRendererFacadeMiddleware
10
 */
11
final class RendererFacade
12
{
13
    /**
14
     * @var RendererInterface
15
     */
16
    private static $renderer;
17
18
    public static function init(RendererInterface $renderer): void
19
    {
20
        self::$renderer = $renderer;
21
    }
22
23
    /**
24
     * Renders the object as a HTML string, to the output.
25
     *
26
     * @param object $object  The object to render
27
     * @param string|null $context A string representing a context that might be used to choose another renderer for the object.
28
     */
29
    public static function render($object, string $context = null): void
30
    {
31
        self::$renderer->render($object, $context);
32
    }
33
}
34