Completed
Pull Request — master (#3)
by David
02:24
created

Block::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 5
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace TheCodingMachine\CMS\Block;
3
4
use TheCodingMachine\CMS\Theme\ThemeDescriptorInterface;
5
6 View Code Duplication
class Block implements BlockInterface, \JsonSerializable
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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