Test Failed
Push — develop ( fe7dfd...f4a85b )
by Paul
08:21
created

VcShortcode::vcShortcodeSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\WPBakery;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
7
abstract class VcShortcode extends \WPBakeryShortCode
1 ignored issue
show
Bug introduced by
The type WPBakeryShortCode 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
    /**
10
     * Override the "vc_map" data with the
11
     * "vc_element_settings_filter" ($settings, $shortcode) filter hook.
12
     */
13
    public static function vcRegister(array $args = []): void
14
    {
15
        vc_map(wp_parse_args($args, [
1 ignored issue
show
Bug introduced by
The function vc_map was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

15
        /** @scrutinizer ignore-call */ 
16
        vc_map(wp_parse_args($args, [
Loading history...
16
            'base' => static::vcShortcode()->shortcode,
17
            'category' => glsr()->name,
18
            'description' => static::vcShortcode()->description,
0 ignored issues
show
Bug introduced by
Accessing description on the interface GeminiLabs\SiteReviews\Contracts\ShortcodeContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
19
            'icon' => static::vcShortcodeIcon(),
20
            'name' => static::vcShortcode()->name,
0 ignored issues
show
Bug introduced by
Accessing name on the interface GeminiLabs\SiteReviews\Contracts\ShortcodeContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
21
            'params' => array_values(array_filter(static::vcShortcodeSettings())),
22
            'php_class_name' => static::class,
23
            'show_settings_on_create' => false,
24
        ]));
25
    }
26
27
    public static function vcShortcode(): ShortcodeContract
28
    {
29
        return glsr(static::vcShortcodeClass());
1 ignored issue
show
Bug Best Practice introduced by
The expression return glsr(static::vcShortcodeClass()) could return the type callable which is incompatible with the type-hinted return GeminiLabs\SiteReviews\Contracts\ShortcodeContract. Consider adding an additional type-check to rule them out.
Loading history...
30
    }
31
32
    abstract public static function vcShortcodeClass(): string;
33
34
    abstract public static function vcShortcodeIcon(): string;
35
36
    /**
37
     * Override attributes for a setting with the 
38
     * "vc_mapper_attribute" ($setting, $shortcode) filter hook.
39
     */
40
    public static function vcShortcodeSettings(): array
41
    {
42
        return [];
43
    }
44
45
    public static function vcTypeOptions(): array
46
    {
47
        $types = glsr()->retrieveAs('array', 'review_types', []);
48
        if (2 > count($types)) {
49
            return [];
50
        }
51
        return [
52
            'type' => 'dropdown',
53
            'heading' => esc_html_x('Limit Reviews by Type', 'admin-text', 'site-reviews'),
54
            'param_name' => 'type',
55
            'std' => 'local',
56
            'value' => array_flip($types),
57
        ];
58
    }
59
}
60