Passed
Pull Request — master (#20)
by Jason
02:04 queued 29s
created

FoxyHelper::getCustomSSL()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dynamic\Foxy\Model;
4
5
use SilverStripe\Core\Config\Configurable;
6
use SilverStripe\Core\Extensible;
7
use SilverStripe\Core\Injector\Injectable;
8
9
class FoxyHelper extends \FoxyCart_Helper
10
{
11
    use Configurable;
12
    use Injectable;
13
    use Extensible;
14
15
    /**
16
     * @var
17
     */
18
    private static $secret;
0 ignored issues
show
introduced by
The private property $secret is not used, and could be removed.
Loading history...
19
20
    /**
21
     * @var
22
     */
23
    protected static $cart_url;
24
25
    /**
26
     * @var
27
     */
28
    private static $custom_ssl;
29
30
    /**
31
     * @param $custom_ssl
32
     */
33
    public static function setCustomSSL($custom_ssl) {
34
        self::$custom_ssl = $custom_ssl;
35
    }
36
37
    /**
38
     * @return mixed
39
     */
40
    public static function getCustomSSL() {
41
        return self::$custom_ssl;
42
    }
43
44
    /**
45
     * FoxyHelper constructor.
46
     * @throws \SilverStripe\ORM\ValidationException
47
     */
48
    public function __construct()
49
    {
50
        self::setCartURL($this->config()->get('cart_url'));
51
        self::setSecret($this->config()->get('secret'));
52
        self::setCustomSSL($this->config()->get('custom_ssl'));
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public static function StoreURL()
59
    {
60
        if (self::config()->get('custom_ssl')) {
61
            return sprintf('https://%s/', self::config()->get('cart_url'));
62
        } else {
63
            return sprintf('https://%s.foxycart.com/', self::config()->get('cart_url'));
64
        }
65
    }
66
67
    /**
68
     * @return string
69
     * @throws \SilverStripe\ORM\ValidationException
70
     */
71
    public static function FormActionURL()
72
    {
73
        return self::StoreURL() . 'cart';
74
    }
75
}
76