SubThemeDescriptor::getAdditionalContext()   A
last analyzed

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 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheCodingMachine\CMS\Theme;
5
6
7
class SubThemeDescriptor implements ThemeDescriptorInterface, \JsonSerializable
8
{
9
    /**
10
     * @var mixed[]
11
     */
12
    private $additionalContext;
13
    /**
14
     * @var ThemeDescriptorInterface
15
     */
16
    private $themeDescriptor;
17
18
    /**
19
     * @param mixed[] $additionalContext
20
     */
21
    public function __construct(ThemeDescriptorInterface $themeDescriptor, array $additionalContext)
22
    {
23
        $this->additionalContext = $additionalContext;
24
        $this->themeDescriptor = $themeDescriptor;
25
    }
26
27
    /**
28
     * @return ThemeDescriptorInterface
29
     */
30
    public function getThemeDescriptor(): ThemeDescriptorInterface
31
    {
32
        return $this->themeDescriptor;
33
    }
34
35
    /**
36
     * @return mixed[]
37
     */
38
    public function getAdditionalContext(): array
39
    {
40
        return $this->additionalContext;
41
    }
42
43
    public function jsonSerialize()
44
    {
45
        return [
46
            'type' => 'subTheme',
47
            'additionalContext' => $this->additionalContext,
48
            'theme' => $this->themeDescriptor
49
        ];
50
    }
51
52
    /**
53
     * Returns the path of the theme.
54
     * This does not have to be an absolute path (it is relative to the theme directory)
55
     *
56
     * @return string|null
57
     */
58
    public function getPath(): ?string
59
    {
60
        return $this->getThemeDescriptor()->getPath();
61
    }
62
}
63