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

Hooks::isEnabled()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
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