Passed
Push — master ( 5a6133...83a442 )
by Jason
03:06
created

FoxyStripePageExtension::onAfterInit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
namespace Dynamic\FoxyStripe\ORM;
4
5
use Dynamic\FoxyStripe\Model\FoxyCart;
6
use Dynamic\FoxyStripe\Model\FoxyStripeSetting;
7
use SilverStripe\Core\Extension;
8
use SilverStripe\View\Requirements;
9
10
class FoxyStripePageExtension extends Extension
11
{
12
    /**
13
     * @throws \SilverStripe\ORM\ValidationException
14
     */
15
    public function onAfterInit()
16
    {
17
        $config = FoxyStripeSetting::current_foxystripe_setting();
18
19
        if ($config->EnableSidecart) {
0 ignored issues
show
Bug Best Practice introduced by
The property EnableSidecart does not exist on Dynamic\FoxyStripe\Model\FoxyStripeSetting. Since you implemented __get, consider adding a @property annotation.
Loading history...
20
            Requirements::javascript(
21
                "https://cdn.foxycart.com/" . FoxyCart::getFoxyCartStoreName() . "/loader.js",
0 ignored issues
show
Bug introduced by
Are you sure Dynamic\FoxyStripe\Model...:getFoxyCartStoreName() of type false|SilverStripe\ORM\FieldType\DBVarchar can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

21
                "https://cdn.foxycart.com/" . /** @scrutinizer ignore-type */ FoxyCart::getFoxyCartStoreName() . "/loader.js",
Loading history...
22
                [
23
                    "async" => true,
24
                    "defer" => true,
25
                ]
26
            );
27
        }
28
    }
29
}
30