RollbarPageExtension   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 23
rs 10
wmc 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getShowRollbar() 0 10 9
A getRollbarClientToken() 0 3 1
1
<?php
2
3
namespace AntonyThorpe\Rollbar;
4
5
use SilverStripe\Control\Director;
6
use SilverStripe\Core\Config\Config;
7
use SilverStripe\Core\Extension;
8
use AntonyThorpe\Rollbar\Rollbar;
9
10
/**
11
 * Extend Page class to provide variables to Rollbar.ss
12
 */
13
class RollbarPageExtension extends Extension
14
{
15
    /**
16
     * Show/no-show of the Rollbar javascript file as set in your config
17
     */
18
    public function getShowRollbar(): bool
19
    {
20
        if (Director::isLive() && Rollbar::config()->show_on_live && Rollbar::config()->show) {
21
            return true;
22
        }
23
24
        if (Director::isDev() && Rollbar::config()->show_on_dev && Rollbar::config()->show) {
25
            return true;
26
        }
27
        return Director::isTest() && Rollbar::config()->show_on_test && Rollbar::config()->show;
28
    }
29
30
    /**
31
     * Provide the site id to the template
32
     */
33
    public function getRollbarClientToken(): string
34
    {
35
        return Rollbar::config()->client_token;
36
    }
37
}
38