Test Failed
Push — develop ( 1fb310...514ddb )
by Paul
09:40
created

Hooks::supportedVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\WPLoyalty;
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->isVersionSupported()) {
15
            $this->notify('WPLoyalty');
16
            return;
17
        }
18
        $this->hook(Controller::class, [
19
            ['filterFieldAfter', 'site-reviews/review-form/fields/visible', 10, 2],
20
            ['onApprovedReview', 'site-reviews/review/approved', 20],
21
            ['onCreatedReview', 'site-reviews/review/created', 20],
22
        ]);
23
    }
24
25
    protected function isInstalled(): bool
26
    {
27
        return class_exists('Wlr\App\Helpers\EarnCampaign')
28
            && class_exists('\Wlr\App\Helpers\Woocommerce')
29
            && class_exists('\Wlr\App\Premium\Helpers\ProductReview')
30
            && class_exists('\Wlr\App\Premium\Helpers\Referral');
31
    }
32
33
    protected function supportedVersion(): string
34
    {
35
        return '1.4.0';
36
    }
37
38
    protected function version(): string
39
    {
40
        return defined('WLR_PLUGIN_VERSION')
41
            ? (string) \WLR_PLUGIN_VERSION
0 ignored issues
show
Bug introduced by
The constant WLR_PLUGIN_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
42
            : '';
43
    }
44
}
45