Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 51
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
LoyaltyConfig
0.00% covered (danger)
0.00%
0 / 51
0.00% covered (danger)
0.00%
0 / 4
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getLoyaltyConfigArray
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
2
 getLoyaltyConfigDefaults
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
2
 getLoyaltyConfigDefaultsArray
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace BuyerKiosk\Core\Loyalty;
4
5class LoyaltyConfig {
6
7    public $dateChanged;
8    public $type;
9    public $d2p;
10    public $p2d;
11    public $minToRedeem;
12    public $maxPointsRedeemable;
13    public $threshold;
14    public $percentOff;
15    public $dollarsOff;
16    public $maximumDiscount;
17    public $expirePoints;
18    public $transTexts;
19
20    public $a_type;
21    public $b_type;
22    public $c_type;
23
24    public $a_amount;
25    public $b_amount;
26    public $c_amount;
27
28    public $a_threshold;
29    public $b_threshold;
30    public $c_threshold;
31
32    public $a_desc;
33    public $b_desc;
34    public $c_desc;
35
36
37    /*
38     * By Default creating a Loyalty Config with no parameters returns a default configuration
39     * Passing a $row variable (created by a select query on a config database) will return the
40     * configuration variables from the database.
41     */
42
43    public function __construct($row = null) {
44        if($row == null) {
45            $this->getLoyaltyConfigDefaults();
46        } else {
47            $this->getLoyaltyConfigArray($row);
48        }
49    }
50
51    public function getLoyaltyConfigArray($row) {
52
53        $this->dateChanged = $row['dateChanged'];
54        $this->type = $row['type'];
55        $this->d2p = $row['d2p'];
56        $this->p2d = $row['p2d'];
57        $this->minToRedeem = $row['minToRedeem'];
58        $this->maxPointsRedeemable = $row['maxPointsRedeemable'];
59        $this->threshold = $row['threshold'];
60        $this->percentOff = $row['percentOff'];
61        $this->dollarsOff = $row['dollarsOff'];
62        $this->maximumDiscount = $row['maximumDiscount'];
63        $this->expirePoints = $row['expirePoints'];
64        $this->a_type = $row['a_type'];
65        $this->b_type = $row['b_type'];
66        $this->c_type = $row['c_type'];
67        $this->a_amount = $row['a_amount'];
68        $this->b_amount = $row['b_amount'];
69        $this->c_amount = $row['c_amount'];
70        $this->a_threshold = $row['a_threshold'];
71        $this->b_threshold = $row['b_threshold'];
72        $this->c_threshold = $row['c_threshold'];
73        $this->a_desc = $row['a_desc'];
74        $this->b_desc = $row['b_desc'];
75        $this->c_desc = $row['c_desc'];
76    }
77    public function getLoyaltyConfigDefaults() {
78        $this->dateChanged = null;
79        $this->type = "1";
80        $this->d2p =  "10";
81        $this->p2d =  "300";
82        $this->minToRedeem = "1000";
83        $this->maxRedeemable = "10000";
84        $this->threshold = "3000";
85        $this->percentOff = "15";
86        $this->dollarsOff = "0";
87        $this->maximumDiscount = "30";
88        $this->expirePoints = "120";
89        $this->transTexts = "1";
90    }
91    public function getLoyaltyConfigDefaultsArray() {
92        return array(
93            "type" => "1",
94            "d2p" => "10",
95            "p2d" => "300",
96            "minToRedeem" => "1000",
97            "maxRedeemable" => "10000",
98            "threshold" => "3000",
99            "percentOff" => "15",
100            "dollarsOff" => "0",
101            "maximumDiscount" => "30",
102            "expirePoints" => "120",
103            "transTexts" => "1"
104        );
105    }
106}