ChecIOExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A contentcontrollerInit() 0 6 2
A getChecIOJs() 0 7 2
1
<?php
2
3
class ChecIOExtension extends SiteTreeExtension
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...
4
{
5
    /**
6
     * Loads the third party javascript during Controller->init()
7
     */
8
    public function contentcontrollerInit()
9
    {
10
        if ($jsPath = ChecIOShortcode::config()->get('third-party-js')) {
11
            Requirements::javascript($jsPath);
12
        }
13
    }
14
15
    /**
16
     * Tries to fetch the inline chec.io JS from cache, failing which it gets it from the URL.
17
     * Should your theme clear requirements, placing this before the closing body tag ensures
18
     * that it always gets loaded.
19
     * @return string
20
     */
21
    public function getChecIOJs()
22
    {
23
        if ($jsPath = ChecIOShortcode::config()->get('third-party-js')) {
24
            return sprintf('<script type="text/javascript" src="%s"></script>', $jsPath);
25
        }
26
        return '';
27
    }
28
}
29