Passed
Push — dependabot/composer/squizlabs/... ( b689d5...f9f311 )
by
unknown
14:25 queued 10:31
created

PrivacyStatement   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 1
b 0
f 0
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A main() 0 20 4
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 * ACC Development Team. Please see team.json for a list of contributors.     *
5
 *                                                                            *
6
 * This is free and unencumbered software released into the public domain.    *
7
 * Please see LICENSE.md for the full licencing statement.                    *
8
 ******************************************************************************/
9
10
namespace Waca\Fragments;
11
12
use Waca\Helpers\MarkdownRenderingHelper;
13
14
trait PrivacyStatement
15
{
16
    protected abstract function assign($name, $value);
17
    protected abstract function templatePath();
18
    protected abstract function setTemplate($name);
19
    protected abstract function skipAlerts();
20
    protected abstract function getSiteConfiguration();
21
22
    protected function main()
23
    {
24
        $path = $this->getSiteConfiguration()->getPrivacyStatementPath();
25
26
        if ($path == null || !file_exists($path)) {
27
            if (!headers_sent()) {
28
                header('HTTP/1.1 404 Not Found');
29
            }
30
31
            $this->skipAlerts();
32
            $this->setTemplate('404.tpl');
33
            return;
34
        }
35
36
        $markdown = file_get_contents($path);
37
38
        $renderer = new MarkdownRenderingHelper();
39
        $this->assign('content', $renderer->doRender($markdown));
40
41
        $this->setTemplate($this->templatePath());
42
    }
43
}