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

Hooks   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
eloc 12
dl 0
loc 26
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 12 3
A isInstalled() 0 3 2
A isEnabled() 0 4 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\LPFW;
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->isEnabled()) {
15
            return;
16
        }
17
        $this->hook(Controller::class, [
18
            ['filterEarnPointTypes', 'lpfw_get_point_earn_source_types'],
19
            ['onApprovedReview', 'site-reviews/review/approved', 20],
20
            ['onCreatedReview', 'site-reviews/review/created', 20],
21
        ]);
22
    }
23
24
    protected function isEnabled(): bool
25
    {
26
        return $this->isInstalled()
27
            && 'yes' === get_option(\LPFW()->Plugin_Constants->EARN_ACTION_PRODUCT_REVIEW, 'yes');
1 ignored issue
show
Bug introduced by
The function LPFW 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

27
            && 'yes' === get_option(/** @scrutinizer ignore-call */ \LPFW()->Plugin_Constants->EARN_ACTION_PRODUCT_REVIEW, 'yes');
Loading history...
28
    }
29
30
    protected function isInstalled(): bool
31
    {
32
        return function_exists('LPFW') && class_exists('LPFW');
33
    }
34
}
35