/** * This method handles the output in the console. * * @param $process_name * @param $total_num_items */ public static function track($process_name, $total_num_items, $num_items_per_iteration = 1) { // If the process name changes, an new process tracking begins. if ($process_name !== self::$process_name) { self::set_new_tracking_process($process_name, $total_num_items, $num_items_per_iteration); } else { /* * It's assumed that a loop starts incrementing the counter "after" * the first loop. Like the for-loop starts incrementing after the * first execution. F.e.: * for ($i = 0; $i <= 100; $i += 5) { * "5" is here after the first execution. */ self::increaseIteration(); // time status self::$elapsed_seconds = time() - self::$process_start_timestamp; $one_percent_total = $total_num_items / 100; $percent_current_output = self::$num_iteration / $one_percent_total; self::outputStatusMessage($total_num_items, $percent_current_output); /* * Send the "finish" message to standard out. */ if (self::$num_iteration >= self::$total_num_items) { self::outputFinishMessage(); static::$debug__num_finish_messages++; static::$debug__percent_output_at_the_end = $percent_current_output; } } }