AbstractAreabrick   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 14
eloc 27
c 2
b 0
f 0
dl 0
loc 145
ccs 15
cts 15
cp 1
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemplateSuffix() 0 3 1
A doAction() 0 3 1
A __construct() 0 12 1
A hasEditTemplate() 0 3 1
A getTemplateLocation() 0 3 1
A getIcon() 0 3 2
A getName() 0 3 2
A action() 0 5 1
A postRenderAction() 0 3 1
A getHtmlTagClose() 0 3 1
A getHtmlTagOpen() 0 3 1
A configure() 0 2 1
1
<?php
2
3
namespace Khusseini\PimcoreRadBrickBundle\Areabricks;
4
5
use Khusseini\PimcoreRadBrickBundle\AreabrickRenderer;
6
use Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick;
7
use Pimcore\Model\Document\Tag\Area\Info;
8
use Symfony\Component\HttpFoundation\Response;
9
10
abstract class AbstractAreabrick extends AbstractTemplateAreabrick
11
{
12
    /**
13
     * @var string
14
     */
15
    private $name;
16
    /**
17
     * @var string
18
     */
19
    private $icon;
20
    /**
21
     * @var string
22
     */
23
    private $label;
24
    /**
25
     * @var string
26
     */
27
    private $openTag = '';
28
    /**
29
     * @var string
30
     */
31
    private $closeTag = '';
32
    /**
33
     * @var bool
34
     */
35
    private $useEdit = false;
36
37
    /**
38
     * @var AreabrickRenderer
39
     */
40
    private $areabrickRenderer;
41
42 2
    public function __construct(
43
        string $name,
44
        AreabrickRenderer $areabrickRenderer
45
    ) {
46 2
        $this->name = $name;
47 2
        $this->areabrickRenderer = $areabrickRenderer;
48 2
        $options = $areabrickRenderer->getAreabrickConfig($name);
49 2
        $this->icon = $options['icon'];
50 2
        $this->label = $options['label'];
51 2
        $this->openTag = $options['open'];
52 2
        $this->closeTag = $options['close'];
53 2
        $this->useEdit = $options['use_edit'];
54 2
    }
55
56
    /**
57
     * @return string
58
     * @codeCoverageIgnore
59
     */
60
    public function getIcon()
61
    {
62
        return $this->icon ?: parent::getIcon();
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::getIcon() targeting Pimcore\Extension\Docume...actAreabrick::getIcon() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
63
    }
64
65
    /**
66
     * @return string
67
     * @codeCoverageIgnore
68
     */
69
    public function getName()
70
    {
71
        return $this->label ?: parent::getName();
72
    }
73
74
    /**
75
     * @return bool
76
     * @codeCoverageIgnore
77
     */
78
    public function hasEditTemplate()
79
    {
80
        return $this->useEdit;
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     *
86
     * @codeCoverageIgnore
87
     */
88
    public function getTemplateLocation()
89
    {
90
        return static::TEMPLATE_LOCATION_GLOBAL;
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     *
96
     * @codeCoverageIgnore
97
     */
98
    public function getTemplateSuffix()
99
    {
100
        return static::TEMPLATE_SUFFIX_TWIG;
101
    }
102
103
    /**
104
     * @return Response|null
105
     */
106 1
    public function action(Info $info)
107
    {
108 1
        $this->areabrickRenderer->render($this->name, $info);
109
110 1
        return $this->doAction($info);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->doAction($info) targeting Khusseini\PimcoreRadBric...ctAreabrick::doAction() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
111
    }
112
113 1
    public function doAction(Info $info): ?Response
0 ignored issues
show
Unused Code introduced by
The parameter $info is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

113
    public function doAction(/** @scrutinizer ignore-unused */ Info $info): ?Response

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
114
    {
115 1
        return null;
116
    }
117
118
    /**
119
     * @codeCoverageIgnore
120
     *
121
     * @param array<string, mixed> $options
122
     */
123
    public function configure(array $options): void
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

123
    public function configure(/** @scrutinizer ignore-unused */ array $options): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
124
    {
125
    }
126
127
    /**
128
     * {@inheritdoc}
129
     *
130
     * @codeCoverageIgnore
131
     */
132
    public function postRenderAction(Info $info)
133
    {
134
        return null;
135
    }
136
137
    /**
138
     * {@inheritdoc}
139
     *
140
     * @codeCoverageIgnore
141
     */
142
    public function getHtmlTagOpen(Info $info)
143
    {
144
        return $this->openTag;
145
    }
146
147
    /**
148
     * {@inheritdoc}
149
     *
150
     * @codeCoverageIgnore
151
     */
152
    public function getHtmlTagClose(Info $info)
153
    {
154
        return $this->closeTag;
155
    }
156
}
157