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

Hooks::run()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 12
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 12
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