Passed
Pull Request — master (#20)
by Jason
01:43
created

FoxyHelper::StoreURL()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 6
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
    {
35
        self::$custom_ssl = $custom_ssl;
36
    }
37
38
    /**
39
     * @return mixed
40
     */
41
    public static function getCustomSSL()
42
    {
43
        return self::$custom_ssl;
44
    }
45
46
    /**
47
     * FoxyHelper constructor.
48
     * @throws \SilverStripe\ORM\ValidationException
49
     */
50
    public function __construct()
51
    {
52
        self::setCartURL($this->config()->get('cart_url'));
53
        self::setSecret($this->config()->get('secret'));
54
        self::setCustomSSL($this->config()->get('custom_ssl'));
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public static function StoreURL()
61
    {
62
        if (self::config()->get('custom_ssl')) {
63
            return sprintf('https://%s/', self::config()->get('cart_url'));
64
        } else {
65
            return sprintf('https://%s.foxycart.com/', self::config()->get('cart_url'));
66
        }
67
    }
68
69
    /**
70
     * @return string
71
     * @throws \SilverStripe\ORM\ValidationException
72
     */
73
    public static function FormActionURL()
74
    {
75
        return self::StoreURL() . 'cart';
76
    }
77
}
78