Reference
Writing Custom Reporters
A reporter is a class implementing ReporterInterface.
<?php
namespace Laminas\Diagnostics\Runner\Reporter;
use ArrayObject;
use Laminas\Diagnostics\Check\CheckInterface as Check;
use Laminas\Diagnostics\Result\Collection as ResultCollection;
use Laminas\Diagnostics\Result\ResultInterface as Result;
interface ReporterInterface
{
public function onStart(ArrayObject $checks, $runnerConfig);
public function onBeforeRun(Check $check);
public function onAfterRun(Check $check, Result $result);
public function onStop(ResultCollection $results);
public function onFinish(ResultCollection $results);
}
A Runner invokes the above methods while running diagnostics in the following order:
onStart- right after callingRunner::run()onBeforeRun- before each individual Check.onAfterRun- after each individual check has finished running.onFinish- after Runner has finished its job.onStop- in case Runner has been interrupted:- when the reporter has returned
falsefrom theonAfterRunmethod - or when the runner is configured with
setBreakOnFailure(true)and one of the checks fails.
- when the reporter has returned
Some reporter methods can be used to interrupt the operation of a diagnostics runner:
onBeforeRun(Check $check)- in case this method returnsfalse, that particular check will be omitted.onAfterRun(Check $check, Result($result))- in case this method returnsfalse, the runner will abort checking.
All other return values are ignored.
laminas/laminas-diagnostics ships with a simple Console reporter that can serve as an example of how to write your own reporters.