Passed
Pull Request — master (#20)
by Jason
01:49
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
use SilverStripe\Dev\Debug;
9
10
class FoxyHelper extends \FoxyCart_Helper
11
{
12
    use Configurable;
13
    use Injectable;
14
    use Extensible;
15
16
    /**
17
     * @var
18
     */
19
    private static $secret;
0 ignored issues
show
introduced by
The private property $secret is not used, and could be removed.
Loading history...
20
21
    /**
22
     * @var
23
     */
24
    protected static $cart_url;
25
26
    /**
27
     * @var
28
     */
29
    private static $custom_ssl;
30
31
    /**
32
     * @param $custom_ssl
33
     */
34
    public static function setCustomSSL($custom_ssl) {
35
        self::$custom_ssl = $custom_ssl;
36
    }
37
38
    /**
39
     * @return mixed
40
     */
41
    public static function getCustomSSL() {
42
        return self::$custom_ssl;
43
    }
44
45
    /**
46
     * FoxyHelper constructor.
47
     * @throws \SilverStripe\ORM\ValidationException
48
     */
49
    public function __construct()
50
    {
51
        self::setCartURL($this->config()->get('cart_url'));
52
        self::setSecret($this->config()->get('secret'));
53
        self::setCustomSSL($this->config()->get('custom_ssl'));
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public static function StoreURL()
60
    {
61
        if (self::config()->get('custom_ssl')) {
62
            return sprintf('https://%s/', self::config()->get('cart_url'));
63
        } else {
64
            return sprintf('https://%s.foxycart.com/', self::config()->get('cart_url'));
65
        }
66
    }
67
68
    /**
69
     * @return string
70
     * @throws \SilverStripe\ORM\ValidationException
71
     */
72
    public static function FormActionURL()
73
    {
74
        return self::StoreURL() . 'cart';
75
    }
76
}
77