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

FoxyHelper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setCustomSSL() 0 3 1
A getCustomSSL() 0 3 1
A StoreURL() 0 6 2
A FormActionURL() 0 3 1
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