Elgg  Version 5.1
Result.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrade;
4 
10 final class Result {
11 
12  private $errors = [];
13 
14  private $failure_count = 0;
15 
16  private $success_count = 0;
17 
18  private $is_complete = false;
19 
27  public function addError($message): void {
28  if (is_array($message)) {
29  $this->errors = $this->errors + $message;
30  } else {
31  $this->errors[] = $message;
32  }
33  }
34 
40  public function getErrors(): array {
41  return $this->errors;
42  }
43 
53  public function addFailures(int $num = 1): void {
54  $this->failure_count += $num;
55  }
56 
62  public function getFailureCount(): int {
63  return $this->failure_count;
64  }
65 
73  public function addSuccesses(int $num = 1): void {
74  $this->success_count += $num;
75  }
76 
82  public function getSuccessCount(): int {
83  return $this->success_count;
84  }
85 
91  public function markComplete(): void {
92  $this->is_complete = true;
93  }
94 
100  public function wasMarkedComplete(): bool {
101  return $this->is_complete === true;
102  }
103 
109  public function toArray(): array {
110  return [
111  'errors' => $this->getErrors(),
112  'numErrors' => $this->getFailureCount(),
113  'numSuccess' => $this->getSuccessCount(),
114  'isComplete' => $this->wasMarkedComplete(),
115  ];
116  }
117 }
addFailures(int $num=1)
Increment failure count.
Definition: Result.php:53
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
markComplete()
Mark the upgrade as complete (not necessarily successful)
Definition: Result.php:91
getErrors()
Get error messages.
Definition: Result.php:40
addSuccesses(int $num=1)
Set an item (or items) as successfully upgraded.
Definition: Result.php:73
toArray()
Export to reports array.
Definition: Result.php:109
wasMarkedComplete()
Has the upgrade been marked complete?
Definition: Result.php:100
getFailureCount()
Get count of failures within the current batch.
Definition: Result.php:62
getSuccessCount()
Get count of successfully upgraded items within the current batch.
Definition: Result.php:82
addError($message)
Add new error message to the batch.
Definition: Result.php:27
Result of a single BatchUpgrade run.
Definition: Result.php:10