| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Plugins\Diagnostics; |
|
|
| use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult; |
|
|
| |
| |
| |
| class DiagnosticReport |
| { |
| |
| |
| |
| private $mandatoryDiagnosticResults; |
|
|
| |
| |
| |
| private $optionalDiagnosticResults; |
|
|
| |
| |
| |
| private $informationalResults; |
|
|
| |
| |
| |
| private $errorCount = 0; |
|
|
| |
| |
| |
| private $warningCount = 0; |
|
|
| |
| |
| |
| |
| |
| public function __construct(array $mandatoryDiagnosticResults, array $optionalDiagnosticResults, array $informationalResults) |
| { |
| $this->mandatoryDiagnosticResults = $mandatoryDiagnosticResults; |
| $this->optionalDiagnosticResults = $optionalDiagnosticResults; |
| $this->informationalResults = $informationalResults; |
|
|
| $this->computeErrorAndWarningCount(); |
| } |
|
|
| |
| |
| |
| public function hasErrors() |
| { |
| return $this->getErrorCount() > 0; |
| } |
|
|
| |
| |
| |
| public function hasWarnings() |
| { |
| return $this->getWarningCount() > 0; |
| } |
|
|
| |
| |
| |
| public function getErrorCount() |
| { |
| return $this->errorCount; |
| } |
|
|
| |
| |
| |
| public function getWarningCount() |
| { |
| return $this->warningCount; |
| } |
|
|
| |
| |
| |
| public function getAllResults() |
| { |
| return array_merge($this->mandatoryDiagnosticResults, $this->optionalDiagnosticResults, $this->informationalResults); |
| } |
|
|
| |
| |
| |
| public function getMandatoryDiagnosticResults() |
| { |
| return $this->mandatoryDiagnosticResults; |
| } |
|
|
| |
| |
| |
| public function getOptionalDiagnosticResults() |
| { |
| return $this->optionalDiagnosticResults; |
| } |
|
|
| public function getInformationalResults() |
| { |
| return $this->informationalResults; |
| } |
|
|
| private function computeErrorAndWarningCount() |
| { |
| foreach ($this->getAllResults() as $result) { |
| switch ($result->getStatus()) { |
| case DiagnosticResult::STATUS_ERROR: |
| $this->errorCount++; |
| break; |
| case DiagnosticResult::STATUS_WARNING: |
| $this->warningCount++; |
| break; |
| } |
| } |
| } |
| } |
|
|