Passed
Push — master ( 2435c4...4321c5 )
by Paul
04:31
created

Multilingual::getPostIds()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 6
rs 10
c 1
b 1
f 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules;
4
5
use GeminiLabs\SiteReviews\Contracts\MultilingualContract as Contract;
6
use GeminiLabs\SiteReviews\Database\OptionManager;
7
8
class Multilingual implements Contract
9
{
10
    protected $integration;
11
    protected $isEnabled = false;
12
13
    public function __construct()
14
    {
15
        $integration = ucfirst(glsr(OptionManager::class)->get('settings.general.multilingual'));
16
        $integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.$integration;
17
        if (!class_exists($integrationClass)) {
18
            glsr_log()->error($integrationClass.' does not exist');
19
            return;
20
        }
21
        $this->integration = glsr($integrationClass);
22
        $this->isEnabled = true;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function getPost($postId)
29
    {
30
        return $this->isEnabled
31
            ? $this->integration->getPostIds($postId)
32
            : $postId;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getPostIds(array $postIds)
39
    {
40
        return $this->isEnabled
41
            ? $this->integration->getPostIds($postIds)
42
            : $postIds;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function isActive()
49
    {
50
        return $this->isEnabled
51
            ? $this->integration->isActive()
52
            : false;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function isEnabled()
59
    {
60
        return $this->isEnabled
61
            ? $this->integration->isEnabled()
62
            : false;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function isSupported()
69
    {
70
        return $this->isEnabled
71
            ? $this->integration->isSupported()
72
            : false;
73
    }
74
}
75