Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 157
0.00% covered (danger)
0.00%
0 / 58
CRAP
0.00% covered (danger)
0.00%
0 / 1
CashActivity
0.00% covered (danger)
0.00%
0 / 157
0.00% covered (danger)
0.00%
0 / 58
4830
0.00% covered (danger)
0.00%
0 / 1
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTimeStamp
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUserId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUserName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTransType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRegister
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDestination
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPennies
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPennyRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNickels
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNickelRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDimes
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDimeRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getQuarters
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getQuarterRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOnes
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOneRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFives
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFiveRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTens
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTenRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTwenties
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTwentyRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFifties
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFiftyRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHundreds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHundredRolls
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTotal
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setId
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 setTimeStamp
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 setUserId
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
12
 setTransType
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 setRegister
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 setDestination
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
 setPennies
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setPennyRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setNickels
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setNickelRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setDimes
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setDimeRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setQuarters
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setQuarterRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setOnes
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setOneRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setFives
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setFiveRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setTens
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setTenRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setTwenties
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setTwentyRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setFifties
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setFiftyRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setHundreds
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setHundredRolls
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setTotal
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 validateAmount
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 validateRolls
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 toArray
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace BuyerKiosk\Cash;
4
5use UserFrosting\MySqlUserLoader;
6
7class CashActivity {
8    private $id;
9    private $timeStamp;
10    private $userId;
11    private $userName;
12    private $transType;
13    private $register;
14    private $destination;
15    private $pennies;
16    private $pennyRolls;
17    private $nickels;
18    private $nickelRolls;
19    private $dimes;
20    private $dimeRolls;
21    private $quarters;
22    private $quarterRolls;
23    private $ones;
24    private $oneRolls;
25    private $fives;
26    private $fiveRolls;
27    private $tens;
28    private $tenRolls;
29    private $twenties;
30    private $twentyRolls;
31    private $fifties;
32    private $fiftyRolls;
33    private $hundreds;
34    private $hundredRolls;
35    private $total;
36
37
38
39    // Validation rules
40    private const RULES = [
41        'transType' => ['Open', 'Close', 'Safe', 'S2R', 'R2S', 'S2B', 'B2S', 'PaidIn', 'PaidOut', 'Void'],
42        'minAmount' => 0,
43        'maxRolls' => 100,
44        'registers' => [
45            '1', '2', '3', '4', '5', '6', '7', '8', '9', '10',
46            '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
47            '21', '22', '23', '24', 'Safe'
48        ],
49        'destinations' => [
50            '1', '2', '3', '4', '5', '6', '7', '8', '9', '10',
51            '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
52            '21', '22', '23', '24', 'Safe', 'None'
53        ],
54    ];
55
56    // Getters
57    public function getId(): ?int { return $this->id; }
58    public function getTimeStamp(): ?string { return $this->timeStamp; }
59    public function getUserId(): ?string { return $this->userId; }
60    public function getUserName(): ?string { return $this->userName; }
61    public function getTransType(): ?string { return $this->transType; }
62    public function getRegister(): ?string { return $this->register; }
63    public function getDestination(): ?string { return $this->destination; }
64    public function getPennies(): ?int { return $this->pennies; }
65    public function getPennyRolls(): ?int { return $this->pennyRolls; }
66    public function getNickels(): ?int { return $this->nickels; }
67    public function getNickelRolls(): ?int { return $this->nickelRolls; }
68    public function getDimes(): ?int { return $this->dimes; }
69    public function getDimeRolls(): ?int { return $this->dimeRolls; }
70    public function getQuarters(): ?int { return $this->quarters; }
71    public function getQuarterRolls(): ?int { return $this->quarterRolls; }
72    public function getOnes(): ?int { return $this->ones; }
73    public function getOneRolls(): ?int { return $this->oneRolls; }
74    public function getFives(): ?int { return $this->fives; }
75    public function getFiveRolls(): ?int { return $this->fiveRolls; }
76    public function getTens(): ?int { return $this->tens; }
77    public function getTenRolls(): ?int { return $this->tenRolls; }
78    public function getTwenties(): ?int { return $this->twenties; }
79    public function getTwentyRolls(): ?int { return $this->twentyRolls; }
80    public function getFifties(): ?int { return $this->fifties; }
81    public function getFiftyRolls(): ?int { return $this->fiftyRolls; }
82    public function getHundreds(): ?int { return $this->hundreds; }
83    public function getHundredRolls(): ?int { return $this->hundredRolls; }
84    public function getTotal(): ?float { return $this->total; }
85
86
87
88    // Setters with validation
89    public function setId(int $id): self {
90        $this->id = $id;
91        return $this;
92    }
93
94    public function setTimeStamp(string $timeStamp): self {
95        if (!strtotime($timeStamp)) {
96            throw new \InvalidArgumentException("Invalid timestamp format");
97        }
98        $this->timeStamp = $timeStamp;
99        return $this;
100    }
101
102    public function setUserId(string $userId): self {
103        if (empty($userId)) {
104            throw new \InvalidArgumentException("User ID cannot be empty");
105        }
106        $userLoader  =  new MySqlUserLoader();
107        $user = $userLoader->fetch($userId);
108        if(!$user) {
109            $this->userName = 'Unknown';
110        } else {
111            $this->userName = $user->display_name;
112        }
113        $this->userId = $userId;
114        return $this;
115    }
116
117    public function setTransType(string $type): self {
118        if (!in_array($type, self::RULES['transType'])) {
119            throw new \InvalidArgumentException("Invalid transaction type: {$type}");
120        }
121        $this->transType = $type;
122        return $this;
123    }
124
125    public function setRegister(string $register): self {
126        if (!in_array($register, self::RULES['registers'])) {
127            throw new \InvalidArgumentException("Invalid register: {$register}");
128        }
129        $this->register = $register;
130        return $this;
131    }
132    public function setDestination($destination = null): self {
133        if($destination === null){
134            $destination = 'None';
135        }
136        if (!in_array($destination, self::RULES['destinations'])) {
137            throw new \InvalidArgumentException("Invalid register for destination: {$destination}");
138        }
139        $this->destination = $destination;
140        return $this;
141    }
142
143    public function setPennies(int $amount): self {
144        $this->validateAmount($amount, 'pennies');
145        $this->pennies = $amount;
146        return $this;
147    }
148
149    public function setPennyRolls(int $rolls): self {
150        $this->validateRolls($rolls, 'penny rolls');
151        $this->pennyRolls = $rolls;
152        return $this;
153    }
154
155    public function setNickels(int $amount): self {
156        $this->validateAmount($amount, 'nickels');
157        $this->nickels = $amount;
158        return $this;
159    }
160
161    public function setNickelRolls(int $rolls): self {
162        $this->validateRolls($rolls, 'nickel rolls');
163        $this->nickelRolls = $rolls;
164        return $this;
165    }
166
167    public function setDimes(int $amount): self {
168        $this->validateAmount($amount, 'dimes');
169        $this->dimes = $amount;
170        return $this;
171    }
172
173    public function setDimeRolls(int $rolls): self {
174        $this->validateRolls($rolls, 'dime rolls');
175        $this->dimeRolls = $rolls;
176        return $this;
177    }
178
179    public function setQuarters(int $amount): self {
180        $this->validateAmount($amount, 'quarters');
181        $this->quarters = $amount;
182        return $this;
183    }
184
185    public function setQuarterRolls(int $rolls): self {
186        $this->validateRolls($rolls, 'quarter rolls');
187        $this->quarterRolls = $rolls;
188        return $this;
189    }
190
191    public function setOnes(int $amount): self {
192        $this->validateAmount($amount, 'ones');
193        $this->ones = $amount;
194        return $this;
195    }
196
197    public function setOneRolls(int $rolls): self {
198        $this->validateRolls($rolls, 'one dollar rolls');
199        $this->oneRolls = $rolls;
200        return $this;
201    }
202
203    public function setFives(int $amount): self {
204        $this->validateAmount($amount, 'fives');
205        $this->fives = $amount;
206        return $this;
207    }
208
209    public function setFiveRolls(int $rolls): self {
210        $this->validateRolls($rolls, 'five dollar rolls');
211        $this->fiveRolls = $rolls;
212        return $this;
213    }
214
215    public function setTens(int $amount): self {
216        $this->validateAmount($amount, 'tens');
217        $this->tens = $amount;
218        return $this;
219    }
220
221    public function setTenRolls(int $rolls): self {
222        $this->validateRolls($rolls, 'ten dollar rolls');
223        $this->tenRolls = $rolls;
224        return $this;
225    }
226
227    public function setTwenties(int $amount): self {
228        $this->validateAmount($amount, 'twenties');
229        $this->twenties = $amount;
230        return $this;
231    }
232
233    public function setTwentyRolls(int $rolls): self {
234        $this->validateRolls($rolls, 'twenty dollar rolls');
235        $this->twentyRolls = $rolls;
236        return $this;
237    }
238
239    public function setFifties(int $amount): self {
240        $this->validateAmount($amount, 'fifties');
241        $this->fifties = $amount;
242        return $this;
243    }
244
245    public function setFiftyRolls(int $rolls): self {
246        $this->validateRolls($rolls, 'fifty dollar rolls');
247        $this->fiftyRolls = $rolls;
248        return $this;
249    }
250
251    public function setHundreds(int $amount): self {
252        $this->validateAmount($amount, 'hundreds');
253        $this->hundreds = $amount;
254        return $this;
255    }
256
257    public function setHundredRolls(int $rolls): self {
258        $this->validateRolls($rolls, 'hundred dollar rolls');
259        $this->hundredRolls = $rolls;
260        return $this;
261    }
262
263
264    public function setTotal(float $total): self {
265        if ($total < 0) {
266            throw new \InvalidArgumentException("Total cannot be negative");
267        }
268        $this->total = $total;
269        return $this;
270    }
271
272
273    // Validation helpers
274    private function validateAmount(int $amount, string $field): void {
275        if ($amount < self::RULES['minAmount']) {
276            throw new \InvalidArgumentException("{$field} cannot be negative");
277        }
278    }
279
280    private function validateRolls(int $rolls, string $field): void {
281        if ($rolls < self::RULES['minAmount']) {
282            throw new \InvalidArgumentException("{$field} cannot be negative");
283        }
284        if ($rolls > self::RULES['maxRolls']) {
285            throw new \InvalidArgumentException("{$field} exceeds maximum allowed");
286        }
287    }
288
289
290
291    // Convert to array for storage/API
292    public function toArray(): array {
293        return [
294            'id' => $this->id,
295            'timeStamp' => $this->timeStamp,
296            'userId' => $this->userId,
297            'userName' => $this->userName,
298            'transType' => $this->transType,
299            'register' => $this->register,
300            'destination' => $this->destination,
301            'pennies' => $this->pennies,
302            'pennyRolls' => $this->pennyRolls,
303            'nickels' => $this->nickels,
304            'nickelRolls' => $this->nickelRolls,
305            'dimes' => $this->dimes,
306            'dimeRolls' => $this->dimeRolls,
307            'quarters' => $this->quarters,
308            'quarterRolls' => $this->quarterRolls,
309            'ones' => $this->ones,
310            'oneRolls' => $this->oneRolls,
311            'fives' => $this->fives,
312            'fiveRolls' => $this->fiveRolls,
313            'tens' => $this->tens,
314            'tenRolls' => $this->tenRolls,
315            'twenties' => $this->twenties,
316            'twentyRolls' => $this->twentyRolls,
317            'fifties' => $this->fifties,
318            'fiftyRolls' => $this->fiftyRolls,
319            'hundreds' => $this->hundreds,
320            'hundredRolls' => $this->hundredRolls,
321            'total' => $this->total
322        ];
323    }
324}