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

Hooks   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
eloc 13
dl 0
loc 22
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 9 2
A isInstalled() 0 8 6
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\MyCred;
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
        $this->hook(Controller::class, [
15
            ['filterHooks', 'mycred_setup_hooks'],
16
            ['filterReferences', 'mycred_all_references'],
17
            ['filterWooreviewHook', 'mycred_setup_hooks', 100], // run after WooCommerce Product Reviews hook
18
        ]);
19
    }
20
21
    protected function isInstalled(): bool
22
    {
23
        return class_exists('myCRED_Hook')
24
            && class_exists('myCRED_Core')
25
            && function_exists('mycred_get_post')
26
            && function_exists('mycred_get_user_meta')
27
            && function_exists('mycred_update_user_meta')
28
            && defined('MYCRED_DEFAULT_TYPE_KEY');
29
    }
30
}
31