Test Failed
Push — develop ( 76157d...9702e2 )
by Paul
08:08
created

ElementTrait::bdActions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Breakdance;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
use GeminiLabs\SiteReviews\Helpers\Arr;
7
use GeminiLabs\SiteReviews\Helpers\Str;
8
9
trait ElementTrait
10
{
11
    /**
12
     * @return array
13
     */
14
    public static function actions()
15
    {
16
        return glsr()->filterArray('breakdance/element/actions', static::bdActions(), static::bdShortcode()->tag);
0 ignored issues
show
Bug introduced by
Accessing tag on the interface GeminiLabs\SiteReviews\Contracts\ShortcodeContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
17
    }
18
19
    /**
20
     * @return array
21
     */
22
    public static function badge()
23
    {
24
        return [
25
            'backgroundColor' => '',
26
            'label' => ' ', // empty because we use this to display an icon
27
            'textColor' => '',
28
        ];
29
    }
30
31
    public static function bdActions(): array
32
    {
33
        return [
34
            'onMountedElement' => [[
35
                'script' => 'GLSR_init();',
36
            ]],
37
            // 'onPropertyChange' => [[
38
            //     'script' => 'GLSR_init();',
39
            // ]],
40
        ];
41
    }
42
43
    public static function bdDependencies(): array
44
    {
45
        return [
46
            [
47
                'builderCondition' => 'return true;',
48
                'frontendCondition' => 'return false;',
49
                'inlineStyles' => [
50
                    '%%SELECTOR%% a, %%SELECTOR%% button {pointer-events: none}',
51
                ],
52
            ],
53
        ];
54
    }
55
56
    abstract public static function bdShortcode(): ShortcodeContract;
57
58
    abstract public static function bdShortcodeClass(): string;
59
60
    /**
61
     * @return string
62
     */
63
    public static function category()
64
    {
65
        return glsr()->id;
66
    }
67
68
    static function className()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
69
    {
70
        return 'breakdance-'.Str::dashCase(static::bdShortcode()->tag);
0 ignored issues
show
Bug introduced by
Accessing tag on the interface GeminiLabs\SiteReviews\Contracts\ShortcodeContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
71
    }
72
73
    public static function dependencies()
74
    {
75
        return glsr()->filterArray('breakdance/element/dependencies', static::bdDependencies(), static::bdShortcode()->tag);
0 ignored issues
show
Bug introduced by
Accessing tag on the interface GeminiLabs\SiteReviews\Contracts\ShortcodeContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public static function name()
82
    {
83
        return static::bdShortcode()->name();
84
    }
85
86
    /**
87
     * @return array
88
     */
89
    public static function nestingRule()
90
    {
91
        return [
92
            'type' => 'final',
93
        ];
94
    }
95
96
    /**
97
     * @return string[]
98
     */
99
    public static function propertyPathsToSsrElementWhenValueChanges()
100
    {
101
        return [
102
            'content',
103
            // 'design',
104
        ];
105
    }
106
107
    /**
108
     * @return array
109
     */
110
    public static function settings()
111
    {
112
        return [
113
            'bypassPointerEvents' => true,
114
            'disableAI' => true,
115
        ];
116
    }
117
118
    /**
119
     * @return array[]
120
     */
121
    public static function settingsControls()
122
    {
123
        return [];
124
    }
125
126
    /**
127
     * @param mixed $propertiesData
128
     * @param mixed $parentPropertiesData
129
     * @param bool  $isBuilder
130
     * @param int   $repeaterItemNodeId
131
     *
132
     * @return string
133
     */
134
    public static function ssr($propertiesData, $parentPropertiesData = [], $isBuilder = false, $repeaterItemNodeId = null)
0 ignored issues
show
Unused Code introduced by
The parameter $repeaterItemNodeId 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

134
    public static function ssr($propertiesData, $parentPropertiesData = [], $isBuilder = false, /** @scrutinizer ignore-unused */ $repeaterItemNodeId = null)

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...
Unused Code introduced by
The parameter $isBuilder 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

134
    public static function ssr($propertiesData, $parentPropertiesData = [], /** @scrutinizer ignore-unused */ $isBuilder = false, $repeaterItemNodeId = null)

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...
Unused Code introduced by
The parameter $parentPropertiesData 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

134
    public static function ssr($propertiesData, /** @scrutinizer ignore-unused */ $parentPropertiesData = [], $isBuilder = false, $repeaterItemNodeId = null)

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...
135
    {
136
        $args = static::ssrArgs(Arr::consolidate($propertiesData));
137
        return static::bdShortcode()->build($args, 'breakdance', false);
138
    }
139
140
    abstract public static function ssrArgs(array $propertiesData): array;
141
142
    /**
143
     * @return string
144
     */
145
    public static function slug()
146
    {
147
        return __CLASS__;
148
    }
149
150
    /**
151
     * @return string
152
     */
153
    public static function template()
154
    {
155
        return '%%SSR%%';
156
    }
157
}
158