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

Multilingual   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 25
dl 0
loc 65
ccs 0
cts 40
cp 0
rs 10
c 1
b 1
f 0
wmc 12

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getPostIds() 0 5 2
A isSupported() 0 5 2
A __construct() 0 10 2
A isActive() 0 5 2
A getPost() 0 5 2
A isEnabled() 0 5 2
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