You are here

public function SiteAuditReportAbstract::toJson in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Report/Abstract.php \SiteAuditReportAbstract::toJson()

Render response using JSON.

Return value

string Format report as JSON.

File

Report/Abstract.php, line 140
Contains \SiteAudit\Report\Abstract.

Class

SiteAuditReportAbstract
Class SiteAuditReportAbstract.

Code

public function toJson() {
  $report = array(
    'percent' => $this->percent,
    'label' => $this
      ->getLabel(),
    'checks' => array(),
  );
  foreach ($this->checks as $check) {
    $report['checks'][get_class($check)] = array(
      'label' => $check
        ->getLabel(),
      'description' => $check
        ->getDescription(),
      'result' => $check
        ->getResult(),
      'action' => $check
        ->renderAction(),
      'score' => $check
        ->getScore(),
    );
  }
  return json_encode($report);
}