0, 'total' => 0, 'label' => '', ); /** * Notes for the module summary (counts, skipped items). * * @var array */ public $stats = array(); /** * Constructor. * * @param string $scan_id Scan id. * @param string $module Module id. * @param float $deadline Deadline (microtime). */ public function __construct( $scan_id, $module, $deadline ) { $this->scan_id = $scan_id; $this->module = $module; $this->deadline = $deadline; } /** * Whether the step must stop now. * * @return bool */ public function out_of_time() { return microtime( true ) >= $this->deadline; } /** * Record a finding. * * @param string $type Type. * @param string $severity Severity. * @param string $item Item. * @param string $path Path or location. * @param string $hash Hash for ignores. * @param array $details Details. */ public function add( $type, $severity, $item, $path, $hash = '', array $details = array() ) { Findings::add( $this->scan_id, $this->module, $type, $severity, $item, $path, $hash, $details ); if ( ! isset( $this->stats['findings'] ) ) { $this->stats['findings'] = 0; } $this->stats['findings']++; } /** * Increase a summary counter. * * @param string $key Counter name. * @param int $by Amount. */ public function count( $key, $by = 1 ) { $this->stats[ $key ] = ( isset( $this->stats[ $key ] ) ? (int) $this->stats[ $key ] : 0 ) + $by; } }