'', 'label' => '', 'category' => '', 'status' => self::STATUS_INFO, 'severity' => self::SEVERITY_INFO, 'summary' => '', 'remediation' => '', 'reference' => '', ); $args = array_merge( $defaults, $args ); $this->id = (string) $args['id']; $this->label = (string) $args['label']; $this->category = (string) $args['category']; $this->status = (string) $args['status']; $this->severity = (string) $args['severity']; $this->summary = (string) $args['summary']; $this->remediation = (string) $args['remediation']; $this->reference = (string) $args['reference']; } /** * Whether this result represents a problem that needs attention. * * @return bool */ public function is_problem() { return in_array( $this->status, array( self::STATUS_WARN, self::STATUS_FAIL ), true ); } /** * Numeric weight used when computing the overall security score. * Higher severity failures cost more points. * * @return int */ public function weight() { switch ( $this->severity ) { case self::SEVERITY_HIGH: return 5; case self::SEVERITY_MEDIUM: return 3; case self::SEVERITY_LOW: return 1; default: return 0; } } /** * Convert to a plain array for storage/JSON. * * @return array */ public function to_array() { return array( 'id' => $this->id, 'label' => $this->label, 'category' => $this->category, 'status' => $this->status, 'severity' => $this->severity, 'summary' => $this->summary, 'remediation' => $this->remediation, 'reference' => $this->reference, ); } /** * Rehydrate from a stored array. * * @param array $data Stored data. * @return Aardwolf_Check_Result */ public static function from_array( array $data ) { return new self( $data ); } }