Passed
Push — develop ( 667a57...839f1b )
by Paul
15:02
created

FusionElement::designConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\FusionBuilder\Elements;
4
5
use GeminiLabs\SiteReviews\Integrations\FusionBuilder\Transformer;
6
use GeminiLabs\SiteReviews\Integrations\IntegrationShortcode;
7
8
abstract class FusionElement extends \Fusion_Element
9
{
10
    use IntegrationShortcode;
11
12
    public static function elementParameters(array $params): array
13
    {
14
        $controls = array_merge($params, static::styleConfig());
0 ignored issues
show
Bug introduced by
The method styleConfig() does not exist on GeminiLabs\SiteReviews\I...\Elements\FusionElement. ( Ignorable by Annotation )

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

14
        $controls = array_merge($params, static::/** @scrutinizer ignore-call */ styleConfig());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
15
        $groups = [ // order is intentional
16
            'design' => esc_html_x('Design', 'admin-text', 'site-reviews'),
17
            'general' => esc_html_x('General', 'admin-text', 'site-reviews'),
18
        ];
19
        $options = [];
20
        foreach ($controls as $name => $args) {
21
            $transform = new Transformer($name, $args);
22
            $control = $transform->control();
23
            if ('select' === $control['type'] && empty($control['value'])) {
24
                continue;
25
            }
26
            $control['group'] = $groups[$control['group']] ?? ucfirst($control['group']);
27
            $options[$name] = $control;
28
        }
29
        return $options;
30
    }
31
32
    public static function registerElement(): void
33
    {
34
        if (!function_exists('fusion_builder_map')) {
35
            return;
36
        }
37
        if (!function_exists('fusion_builder_frontend_data')) {
38
            return;
39
        }
40
        $instance = glsr(static::shortcodeClass());
41
        $parameters = static::elementParameters($instance->settings());
42
        $parameters = glsr()->filterArray("fusion-builder/controls/{$instance->tag}", $parameters);
43
        fusion_builder_map(fusion_builder_frontend_data(static::class, [
44
            'icon' => static::shortcodeIcon(),
45
            'name' => $instance->name,
46
            'params' => $parameters,
47
            'shortcode' => $instance->tag,
48
        ]));
49
    }
50
51
    protected static function designConfig(): array
52
    {
53
        return [];
54
    }
55
56
    abstract protected static function shortcodeIcon(): string;
57
}
58