BugherdHeroTool::getProjectKey()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
class BugherdHeroTool extends Extension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
3
{
4
    /**
5
     * Function which reads the Bugherd Key from the Configuration
6
     */
7
    public function getProjectKey()
8
    {
9
        $return =  Config::inst()->get('BugherdHeroTool', 'project_key');
10
        if ($return == '') {
11
            $return =  false;
12
        }
13
        return $return;
14
    }
15
16
    public function getEnvType()
17
    {
18
        $return = Config::inst()->get('BugherdHeroTool', 'environment_type');
19
20
        if ($return == '') {
21
            $return =  'dev';
22
        }
23
        return $return;
24
    }
25
26
    public function getMemberStatus()
27
    {
28
        $return = Config::inst()->get('BugherdHeroTool', 'member_status');
29
        if ($return == '') {
30
            $return = false;
31
        }
32
        return $return;
33
    }
34
35
36
37
    /**
38
     * Function which loads the bugherd template into the Website
39
    */
40
    public function onAfterInit()
41
    {
42
        $project_key = $this->getProjectKey();
43
        $env_type = $this->getEnvType();
44
        $member_status = $this->getMemberStatus();
45
      
46
        if ($project_key) {
47
            if ($env_type == Config::inst()->get('Director', 'environment_type')) {
48
                if (($member_status && Member::currentUserID() != 0) || !$member_status) {
49
                    Requirements::customScript($this->owner->renderWith('BugherdHeroTool'), 'BugherdHeroTool');
50
                }
51
            }
52
        }
53
    }
54
}
55