Test Failed
Push — main ( dff822...945f16 )
by Paul
12:03 queued 06:06
created

FusionElement   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
eloc 33
c 1
b 0
f 1
dl 0
loc 52
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A optionReviewTypes() 0 13 2
B optionAssignedTerms() 0 29 6
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\FusionBuilder;
4
5
use GeminiLabs\SiteReviews\Commands\EnqueuePublicAssets;
6
7
abstract class FusionElement extends \Fusion_Element
0 ignored issues
show
Bug introduced by
The type Fusion_Element was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
{
9
    abstract public static function elementParameters(): array;
10
11
    public static function optionAssignedTerms(string $heading, string $description = ''): array
12
    {
13
        $isFusionEditor = function_exists('is_fusion_editor') && is_fusion_editor();
14
        if ($isFusionEditor && function_exists('fusion_builder_shortcodes_categories')) {
15
            $terms = fusion_builder_shortcodes_categories(glsr()->taxonomy, false, '', 26);
16
        } else {
17
            $terms = [];
18
        }
19
        $option = [
20
            'default' => '',
21
            'heading' => $heading,
22
            'param_name' => 'assigned_terms',
23
            'placeholder_text' => esc_attr_x('Select or Leave Blank', 'admin-text', 'site-reviews'),
24
            'type' => 'multiple_select',
25
            'value' => $terms,
26
        ];
27
        if (!empty($description)) {
28
            $option['description'] = $description;
29
        }
30
        if (count($terms) > 25) {
31
            $option['type'] = 'ajax_select';
32
            $option['ajax'] = 'fusion_search_query';
33
            $option['value'] = [];
34
            $option['ajax_params'] = [
35
                'taxonomy' => glsr()->taxonomy,
36
                'use_slugs' => true,
37
            ];
38
        }
39
        return $option;
40
    }
41
42
    public static function optionReviewTypes(): array
43
    {
44
        $types = glsr()->retrieveAs('array', 'review_types', []);
45
        if (2 > count($types)) {
46
            return [];
47
        }
48
        return [
49
            'default' => 'local',
50
            'heading' => esc_attr_x('Limit the Review Type', 'admin-text', 'site-reviews'),
51
            'param_name' => 'type',
52
            'placeholder_text' => esc_attr_x('Select or Leave Blank', 'admin-text', 'site-reviews'),
53
            'type' => 'multiple_select',
54
            'value' => $types,
55
        ];
56
    }
57
58
    abstract public static function registerElement(): void;
59
}
60