5 * Contains \Drupal\security_review\CheckResult.
8 namespace Drupal\security_review;
11 * Used to define the result of a Check.
21 * Stores the parent Check.
23 * @var \Drupal\security_review\Check $check
28 * Stores the outcome of the check.
37 * @var array $findings
42 * Stores the timestamp of the check run.
49 * Whether the result should be shown on the UI.
56 * Constructs an immutable CheckResult.
58 * @param \Drupal\security_review\Check $check
59 * The Check that created this result.
61 * The result integer (see the constants defined above).
62 * @param array $findings
65 * The timestamp of the check run.
66 * @param bool $visible
67 * The visibility of the result.
69 public function __construct(Check $check, $result, array $findings, $visible = TRUE, $time = NULL) {
70 // Set the parent check.
71 $this->check = $check;
73 // Set the result value.
74 $result = intval($result);
75 if ($result < self::SUCCESS || $result > self::INFO) {
78 $this->result = $result;
81 $this->findings = $findings;
83 // Set the visibility.
84 $this->visible = $visible;
91 $this->time = intval($time);
96 * Combines two CheckResults.
98 * Combines two CheckResults and returns a new one with the old one's fields
99 * except for the findings which are copied from the fresh result.
101 * @param \Drupal\security_review\CheckResult $old
102 * The old result to clone.
103 * @param \Drupal\security_review\CheckResult $fresh
104 * The new result to copy the findings from.
106 * @return \Drupal\security_review\CheckResult
107 * The combined result.
109 public static function combine(CheckResult $old, CheckResult $fresh) {
110 return new CheckResult($old->check, $old->result, $fresh->findings, $old->visible, $old->time);
114 * Returns the parent Check.
116 * @return \Drupal\security_review\Check
117 * The Check that created this result.
119 public function check() {
124 * Returns the outcome of the check.
127 * The result integer.
129 public function result() {
130 return $this->result;
134 * Returns the findings.
137 * The findings. Contents of this depends on the actual check.
139 public function findings() {
140 return $this->findings;
144 * Returns the timestamp.
147 * The timestamp the result was created on.
149 public function time() {
154 * Returns the visibility of the result.
157 * Whether the result should be shown on the UI.
159 public function isVisible() {
160 return $this->visible;
164 * Returns the result message.
167 * The result message for this result.
169 public function resultMessage() {
170 return $this->check->getMessage($this->result);