1 | <?php |
||
9 | class Statistics |
||
10 | { |
||
11 | /** |
||
12 | * @var array Statistics relating to the file analysis. |
||
13 | */ |
||
14 | protected static $statistics = [ |
||
15 | 'rows_with_errors' => [], |
||
16 | 'percent_rows_with_errors' => 0, |
||
17 | 'rows_analysed' => 0 |
||
18 | ]; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * Reset the statistics. |
||
23 | */ |
||
24 | 81 | public static function reset() |
|
32 | |||
33 | |||
34 | /** |
||
35 | * Get the statistics about the file analysis. |
||
36 | * |
||
37 | * @return array The statistics. |
||
38 | */ |
||
39 | 54 | public function getStatistics() |
|
49 | |||
50 | |||
51 | /** |
||
52 | * Add the row number of a row with an error to the analysis statistics. |
||
53 | * |
||
54 | * @param int $rowNumber The position of the row with the error in the CSV file. |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | 48 | public function setErrorRow($rowNumber) |
|
62 | |||
63 | |||
64 | /** |
||
65 | * Set the number of rows that have been analysed. |
||
66 | * |
||
67 | * @param int $rowsAnalysedCount The number of rows analysed. |
||
68 | * |
||
69 | * @return void |
||
70 | */ |
||
71 | 72 | public function setRowsAnalysed($rowsAnalysedCount) |
|
75 | |||
76 | |||
77 | /** |
||
78 | * Clean the rows with errors statistic. |
||
79 | * This removes duplicated records where the same row has had multiple errors. |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | 54 | private function cleanErrorRow() |
|
87 | |||
88 | |||
89 | /** |
||
90 | * Get the percentage of analysed rows that have had a error with them. |
||
91 | * |
||
92 | * @return int The percentage. |
||
93 | */ |
||
94 | 54 | private function getErrorRowPercent() |
|
98 | } |