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

SubThemeDescriptor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 6 6 1
A getAdditionalContext() 3 3 1
A __construct() 4 4 1
A getThemeDescriptor() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
4
namespace TheCodingMachine\CMS\Theme;
5
6
7 View Code Duplication
class SubThemeDescriptor implements ThemeDescriptorInterface, \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...
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