Block   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getThemeDescriptor() 0 3 1
A __construct() 0 4 1
A getContext() 0 3 1
A jsonSerialize() 0 5 1
1
<?php
2
namespace TheCodingMachine\CMS\Block;
3
4
use TheCodingMachine\CMS\Theme\ThemeDescriptorInterface;
5
6
class Block implements BlockInterface, \JsonSerializable
7
{
8
    /**
9
     * @var ThemeDescriptorInterface
10
     */
11
    private $themeDescriptor;
12
    /**
13
     * @var mixed[]
14
     */
15
    private $context;
16
17
    /**
18
     * @param ThemeDescriptorInterface $themeDescriptor
19
     * @param mixed[] $context
20
     */
21
    public function __construct(ThemeDescriptorInterface $themeDescriptor, array $context)
22
    {
23
        $this->themeDescriptor = $themeDescriptor;
24
        $this->context = $context;
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 getContext(): array
39
    {
40
        return $this->context;
41
    }
42
43
    public function jsonSerialize()
44
    {
45
        return [
46
            'context' => $this->context,
47
            'theme' => $this->themeDescriptor
48
        ];
49
    }
50
}
51