X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fsecurity_review%2Fsrc%2FCheckResult.php;fp=web%2Fmodules%2Fcontrib%2Fsecurity_review%2Fsrc%2FCheckResult.php;h=7096430e43a4c7cae3ac573e8e74ee50ba91dab4;hp=0000000000000000000000000000000000000000;hb=ba1b5c55c66590c41ccc9844d3e62391b0399abb;hpb=93ef30d42f68e55d11d97312531118bbcd4cf318 diff --git a/web/modules/contrib/security_review/src/CheckResult.php b/web/modules/contrib/security_review/src/CheckResult.php new file mode 100644 index 000000000..7096430e4 --- /dev/null +++ b/web/modules/contrib/security_review/src/CheckResult.php @@ -0,0 +1,173 @@ +check = $check; + + // Set the result value. + $result = intval($result); + if ($result < self::SUCCESS || $result > self::INFO) { + $result = self::INFO; + } + $this->result = $result; + + // Set the findings. + $this->findings = $findings; + + // Set the visibility. + $this->visible = $visible; + + // Set the timestamp. + if (!is_int($time)) { + $this->time = time(); + } + else { + $this->time = intval($time); + } + } + + /** + * Combines two CheckResults. + * + * Combines two CheckResults and returns a new one with the old one's fields + * except for the findings which are copied from the fresh result. + * + * @param \Drupal\security_review\CheckResult $old + * The old result to clone. + * @param \Drupal\security_review\CheckResult $fresh + * The new result to copy the findings from. + * + * @return \Drupal\security_review\CheckResult + * The combined result. + */ + public static function combine(CheckResult $old, CheckResult $fresh) { + return new CheckResult($old->check, $old->result, $fresh->findings, $old->visible, $old->time); + } + + /** + * Returns the parent Check. + * + * @return \Drupal\security_review\Check + * The Check that created this result. + */ + public function check() { + return $this->check; + } + + /** + * Returns the outcome of the check. + * + * @return int + * The result integer. + */ + public function result() { + return $this->result; + } + + /** + * Returns the findings. + * + * @return array + * The findings. Contents of this depends on the actual check. + */ + public function findings() { + return $this->findings; + } + + /** + * Returns the timestamp. + * + * @return int + * The timestamp the result was created on. + */ + public function time() { + return $this->time; + } + + /** + * Returns the visibility of the result. + * + * @return bool + * Whether the result should be shown on the UI. + */ + public function isVisible() { + return $this->visible; + } + + /** + * Returns the result message. + * + * @return string + * The result message for this result. + */ + public function resultMessage() { + return $this->check->getMessage($this->result); + } + +}