Test Failed
Push — develop ( 1da57b...1707fa )
by Paul
07:25
created

Hooks   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 8
eloc 17
dl 0
loc 36
rs 10
c 2
b 0
f 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isInstalled() 0 3 2
A supportedVersion() 0 3 1
A version() 0 6 2
A run() 0 15 3
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\FusionBuilder;
4
5
use GeminiLabs\SiteReviews\Integrations\IntegrationHooks;
6
7
class Hooks extends IntegrationHooks
8
{
9
    public function run(): void
10
    {
11
        if (!$this->isInstalled()) {
12
            return;
13
        }
14
        if (!$this->isVersionSupported()) {
15
            $this->notify('Fusion Builder');
16
            return;
17
        }
18
        $this->hook(Controller::class, [
19
            ['enqueueBuilderStyles', 'fusion_builder_enqueue_live_scripts'],
20
            ['filterButtonClass', 'site-reviews/defaults/style-classes/defaults'],
21
            ['filterPublicInlineScript', 'site-reviews/enqueue/public/inline-script/after'],
22
            ['onActivated', 'site-reviews/activated'],
23
            ['registerFusionElements', 'fusion_builder_before_init'],
24
        ]);
25
    }
26
27
    protected function isInstalled(): bool
28
    {
29
        return class_exists('FusionBuilder') && defined('FUSION_BUILDER_VERSION');
30
    }
31
32
    protected function supportedVersion(): string
33
    {
34
        return '3.11.0';
35
    }
36
37
    protected function version(): string
38
    {
39
        if (defined('FUSION_BUILDER_VERSION')) {
40
            return (string) \FUSION_BUILDER_VERSION;
41
        }
42
        return '';
43
    }
44
}
45