Elgg  Version 3.0
Result.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrade;
4 
8 final class Result {
9 
10  private $errors = [];
11 
12  private $failure_count = 0;
13 
14  private $success_count = 0;
15 
16  private $is_complete = false;
17 
24  public function addError($message) {
25  if (is_array($message)) {
26  $this->errors = $this->errors + $message;
27  } else {
28  $this->errors[] = $message;
29  }
30  }
31 
37  public function getErrors() {
38  return $this->errors;
39  }
40 
49  public function addFailures($num = 1) {
50  $this->failure_count += $num;
51  }
52 
58  public function getFailureCount() {
59  return $this->failure_count;
60  }
61 
68  public function addSuccesses($num = 1) {
69  $this->success_count += $num;
70  }
71 
77  public function getSuccessCount() {
78  return $this->success_count;
79  }
80 
86  public function markComplete() {
87  $this->is_complete = true;
88  }
89 
96  public function wasMarkedComplete() {
97  return $this->is_complete === true;
98  }
99 
104  public function toArray() {
105  return [
106  'errors' => $this->getErrors(),
107  'numErrors' => $this->getFailureCount(),
108  'numSuccess' => $this->getSuccessCount(),
109  'isComplete' => $this->wasMarkedComplete(),
110  ];
111  }
112 }
markComplete()
Mark the upgrade as complete (not necessarily successful)
Definition: Result.php:86
getErrors()
Get error messages.
Definition: Result.php:37
addSuccesses($num=1)
Set an item (or items) as successfully upgraded.
Definition: Result.php:68
toArray()
Export to reports array.
Definition: Result.php:104
wasMarkedComplete()
Has the upgrade been marked complete?
Definition: Result.php:96
addFailures($num=1)
Increment failure count.
Definition: Result.php:49
getFailureCount()
Get count of failures within the current batch.
Definition: Result.php:58
getSuccessCount()
Get count of successfully upgraded items within the current batch.
Definition: Result.php:77
addError($message)
Add new error message to the batch.
Definition: Result.php:24
Result of a single BatchUpgrade run.
Definition: Result.php:8