| Code Coverage
| Classes and Traits | Functions and Methods | Lines
Total | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 2 / 2 | CRAP | 100.00% covered (success) | 100.00% | 7 / 7
Baseball | 100.00% covered (success) | 100.00% | 1 / 1 | 100.00% covered (success) | 100.00% | 2 / 2 | 3 | 100.00% covered (success) | 100.00% | 7 / 7
calc_avg($ab,$hits) | 100.00% covered (success) | 100.00% | 1 / 1 | 2 | 100.00% covered (success) | 100.00% | 6 / 6
submitAtBat($playerid,$result) | 100.00% covered (success) | 100.00% | 1 / 1 | 1 | 100.00% covered (success) | 100.00% | 1 / 1

1 | <?php
2 | namespace stats;
3 |
4 | class Baseball
5 | {
6 | public function calc_avg($ab,$hits)
7 | {
8 | if ($ab == 0)
9 | {
10 | $avg = "0.000";
11 | }
12 | else
13 | {
14 | $avg = number_format($hits/$ab,3);
15 | }
16 | return $avg;
17 | }
18 |
19 | public function submitAtBat($playerid,$result)
20 | {
21 | //insert into database
22 | return true;
23 | }
24 | }
25 | ?>