Passed
Push — master ( 9383fa...213b33 )
by Stéphane
21:22
created

Config::hasPlausibleAnalyticsDomain()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php namespace Todaymade\Daux\Format\HTML;
2
3
use Todaymade\Daux\BaseConfig;
4
5
class Config extends BaseConfig
6
{
7 6
    private function prepareGithubUrl($url)
8
    {
9 6
        $url = str_replace('http://', 'https://', $url);
10
11
        return [
12 6
            'name' => 'GitHub',
13 6
            'basepath' => (strpos($url, 'https://github.com/') === 0 ? '' : 'https://github.com/') . trim($url, '/'),
14
        ];
15
    }
16
17 8
    public function getEditOn()
18
    {
19 8
        if ($this->hasValue('edit_on')) {
20 2
            $edit_on = $this->getValue('edit_on');
21 2
            if (is_string($edit_on)) {
22 1
                return $this->prepareGithubUrl($edit_on);
23
            }
24 1
            $edit_on['basepath'] = rtrim($edit_on['basepath'], '/');
25
26 1
            return $edit_on;
27
        }
28
29
        if ($this->hasValue('edit_on_github')) {
30 6
            return $this->prepareGithubUrl($this->getValue('edit_on_github'));
31 5
        }
32
33
        return null;
34 1
    }
35
36
    public function hasSearch()
37
    {
38
        return $this->hasValue('search') && $this->getValue('search');
39
    }
40
41
    public function showDateModified()
42
    {
43
        return $this->hasValue('date_modified') && $this->getValue('date_modified');
44
    }
45
46
    public function showPreviousNextLinks()
47
    {
48
        if ($this->hasValue('jump_buttons')) {
49
            return $this->getValue('jump_buttons');
50
        }
51
52
        return true;
53
    }
54
55
    public function showCodeToggle()
56
    {
57
        if ($this->hasValue('toggle_code')) {
58
            return $this->getValue('toggle_code');
59
        }
60
61
        return true;
62
    }
63
64 1
    public function hasAutomaticTableOfContents(): bool
65
    {
66 1
        return $this->hasValue('auto_toc') && $this->getValue('auto_toc');
67
    }
68
69
    public function hasGoogleAnalytics()
70
    {
71
        return $this->hasValue('google_analytics') && $this->getValue('google_analytics');
72
    }
73
74
    public function getGoogleAnalyticsId()
75
    {
76
        return $this->getValue('google_analytics');
77
    }
78
79
    public function hasPlausibleAnalyticsDomain()
80
    {
81
        return $this->hasValue('plausible_domain') && $this->getValue('plausible_domain');
82
    }
83
84
    public function getPlausibleAnalyticsDomain()
85
    {
86
        return $this->getValue('plausible_domain');
87
    }
88
89
    public function hasPiwikAnalytics()
90
    {
91
        return $this->getValue('piwik_analytics') && $this->hasValue('piwik_analytics_id');
92
    }
93
94
    public function getPiwikAnalyticsId()
95
    {
96
        return $this->getValue('piwik_analytics_id');
97
    }
98
99
    public function getPiwikAnalyticsUrl()
100
    {
101
        return $this->getValue('piwik_analytics');
102
    }
103
104
    public function hasPoweredBy()
105
    {
106
        return $this->hasValue('powered_by') && !empty($this->getValue('powered_by'));
107
    }
108
109
    public function getPoweredBy()
110
    {
111
        return $this->getValue('powered_by');
112
    }
113
114
    public function hasTwitterHandles()
115
    {
116
        return $this->hasValue('twitter') && !empty($this->getValue('twitter'));
117
    }
118
119
    public function getTwitterHandles()
120
    {
121
        return $this->getValue('twitter');
122
    }
123
124
    public function hasLinks()
125
    {
126
        return $this->hasValue('links') && !empty($this->getValue('links'));
127
    }
128
129
    public function getLinks()
130
    {
131
        return $this->getValue('links');
132
    }
133
134
    public function hasRepository()
135
    {
136
        return $this->hasValue('repo') && !empty($this->getValue('repo'));
137
    }
138
139
    public function getRepository()
140
    {
141
        return $this->getValue('repo');
142
    }
143
144
    public function hasButtons()
145
    {
146
        return $this->hasValue('buttons') && !empty($this->getValue('buttons'));
147
    }
148
149
    public function getButtons()
150
    {
151
        return $this->getValue('buttons');
152
    }
153
154
    public function hasLandingPage()
155
    {
156
        if ($this->hasValue('auto_landing')) {
157
            return $this->getValue('auto_landing');
158
        }
159
160
        return true;
161
    }
162
163
    public function hasBreadcrumbs()
164
    {
165
        if ($this->hasValue('breadcrumbs')) {
166
            return $this->getValue('breadcrumbs');
167 55
        }
168
169 55
        return true;
170
    }
171
172
    public function getBreadcrumbsSeparator()
173
    {
174
        return $this->getValue('breadcrumb_separator');
175
    }
176
177
    public function getTheme()
178
    {
179
        return $this->getValue('theme');
180
    }
181
182
    public function hasThemeVariant()
183
    {
184
        return $this->hasValue('theme-variant') && !empty($this->getValue('theme-variant'));
185
    }
186
187
    public function getThemeVariant()
188
    {
189
        return $this->getValue('theme-variant');
190
    }
191
}
192