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

IntegrationHooks::isInstalled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations;
4
5
use GeminiLabs\SiteReviews\Hooks\AbstractHooks;
6
use GeminiLabs\SiteReviews\Modules\Notice;
7
use GeminiLabs\SiteReviews\Modules\Sanitizer;
8
9
abstract class IntegrationHooks extends AbstractHooks
10
{
11
    protected function isEnabled(): bool
12
    {
13
        return true;
14
    }
15
16
    protected function isInstalled(): bool
17
    {
18
        return true;
19
    }
20
21
    protected function isVersionSupported(): bool
22
    {
23
        $version = glsr(Sanitizer::class)->sanitizeVersion($this->version());
24
        $supportedVersion = glsr(Sanitizer::class)->sanitizeVersion($this->supportedVersion());
25
        if (empty($supportedVersion)) {
26
            return true;
27
        }
28
        return version_compare($version, $supportedVersion, '>=');
1 ignored issue
show
Bug Best Practice introduced by
The expression return version_compare($...supportedVersion, '>=') could return the type integer which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
29
    }
30
31
    protected function notify(string $name): void
32
    {
33
        $notice = _x('Update %s to v%s or higher to enable the integration with Site Reviews.', 'admin-text', 'site-reviews');
34
        $version = glsr(Sanitizer::class)->sanitizeVersion($this->supportedVersion());
35
        glsr(Notice::class)->addWarning(sprintf($notice, $name, $version));
36
    }
37
38
    protected function supportedVersion(): string
39
    {
40
        return '';
41
    }
42
43
    protected function version(): string
44
    {
45
        return '';
46
    }
47
}
48