Test Failed
Push — develop ( 9873ab...1da57b )
by Paul
13:43
created

Hooks   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
eloc 15
dl 0
loc 30
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 13 3
A isWooEnabled() 0 6 4
A isInstalled() 0 3 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Divi;
4
5
use GeminiLabs\SiteReviews\Hooks\AbstractHooks;
6
7
class Hooks extends AbstractHooks
8
{
9
    public function run(): void
10
    {
11
        if (!$this->isInstalled()) {
12
            return;
13
        }
14
        $this->hook(Controller::class, [
15
            ['filterDynamicAssets', 'et_dynamic_assets_modules_atf', 10, 2],
16
            ['filterPaginationLinks', 'site-reviews/paginate_links', 10, 2],
17
            ['registerDiviModules', 'divi_extensions_init'],
18
        ]);
19
        if ($this->isWooEnabled()) {
20
            $this->hook(Controller::class, [
21
                ['filterInlineWooStyles', 'site-reviews/enqueue/public/inline-styles'],
22
            ]);
23
        }
24
    }
25
26
    protected function isInstalled(): bool
27
    {
28
        return 'Divi' === wp_get_theme(get_template())->get('Name');
29
    }
30
31
    protected function isWooEnabled(): bool
32
    {
33
        return 'yes' === $this->option('integrations.woocommerce.enabled')
34
            && 'yes' === get_option('woocommerce_enable_reviews', 'yes')
35
            && class_exists('WooCommerce')
36
            && function_exists('WC');
37
    }
38
}
39