Code Duplication    Length = 45-45 lines in 2 locations

src/Block/Block.php 1 location

@@ 6-50 (lines=45) @@
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

src/Theme/SubThemeDescriptor.php 1 location

@@ 7-51 (lines=45) @@
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