Passed
Pull Request — master (#2)
by David
02:02
created

SubTheme::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheCodingMachine\CMS\Theme;
5
6
7
use Psr\Http\Message\StreamInterface;
8
use TheCodingMachine\CMS\RenderableInterface;
9
10
/**
11
 * This class is an adaptator around a theme that adds additional information in the context.
12
 */
13
class SubTheme implements RenderableInterface
14
{
15
    /**
16
     * @var RenderableInterface
17
     */
18
    private $theme;
19
    /**
20
     * @var mixed[]
21
     */
22
    private $additionalContext;
23
24
    /**
25
     * @param RenderableInterface $theme
26
     * @param mixed[] $additionalContext
27
     */
28
    public function __construct(RenderableInterface $theme, array $additionalContext)
29
    {
30
        $this->theme = $theme;
31
        $this->additionalContext = $additionalContext;
32
    }
33
34
    /**
35
     * Renders (as a stream) the data passed in parameter.
36
     *
37
     * @param mixed[] $context
38
     * @return StreamInterface
39
     */
40
    public function render(array $context): StreamInterface
41
    {
42
        return $this->theme->render(array_merge($this->additionalContext, $context));
43
    }
44
}
45