Passed
Push — main ( 62790e...23fbb2 )
by Paul
13:43 queued 05:55
created

PremiumNotice::hasPermission()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Notices;
4
5
class PremiumNotice extends AbstractNotice
6
{
7
    protected function canRender(): bool
8
    {
9
        if (empty(glsr()->retrieveAs('array', 'site-reviews-premium'))) {
10
            return false;
11
        }
12
        return parent::canRender();
13
    }
14
15
    protected function data(): array
16
    {
17
        return [
18
            'addons' => glsr()->retrieveAs('array', 'site-reviews-premium'),
19
        ];
20
    }
21
22
    protected function hasPermission(): bool
23
    {
24
        return true;
25
    }
26
27
    protected function isDismissible(): bool
28
    {
29
        return false;
30
    }
31
32
    protected function isNoticeScreen(): bool
33
    {
34
        $screen = glsr_current_screen();
35
        $screenIds = ['dashboard', 'plugins', 'update-core'];
36
        if (in_array($screen->id, $screenIds)) {
37
            return true;
38
        }
39
        if (method_exists($screen, 'in_admin') && $screen->in_admin('network')) {
40
            return true;
41
        }
42
        return parent::isNoticeScreen();
43
    }
44
}
45