SapphireInfo   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 9

4 Methods

Rating   Name   Duplication   Size   Complexity  
A BaseURL() 0 3 1
A EnvironmentType() 0 8 3
A Version() 0 7 2
A init() 0 5 3
1
<?php
2
3
namespace SilverStripe\Dev;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\Director;
7
use SilverStripe\Security\Permission;
8
use SilverStripe\Security\Security;
9
10
/**
11
 * Returns information about the current site instance.
12
 */
13
class SapphireInfo extends Controller
14
{
15
    private static $allowed_actions = array(
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
16
        'baseurl',
17
        'version',
18
        'environmenttype',
19
    );
20
21
    protected function init()
22
    {
23
        parent::init();
24
        if (!Director::is_cli() && !Permission::check('ADMIN')) {
25
            Security::permissionFailure();
26
        }
27
    }
28
29
    public function Version()
30
    {
31
        $sapphireVersion = file_get_contents(FRAMEWORK_PATH . '/silverstripe_version');
32
        if (!$sapphireVersion) {
33
            $sapphireVersion = _t('SilverStripe\\Admin\\LeftAndMain.VersionUnknown', 'unknown');
34
        }
35
        return $sapphireVersion;
36
    }
37
38
    public function EnvironmentType()
39
    {
40
        if (Director::isLive()) {
41
            return "live";
42
        } elseif (Director::isTest()) {
43
            return "test";
44
        } else {
45
            return "dev";
46
        }
47
    }
48
49
    public function BaseURL()
50
    {
51
        return Director::absoluteBaseURL();
52
    }
53
}
54