*/ class struct_report { /** * @var string * @author Christian Fraß */ public $incident; /** * @var array record * @author Christian Fraß */ public $details; /** * @var int $timestamp UNIX timestamp * @author Christian Fraß */ public $timestamp; /** * @param string $incident * @param array $details * @author Christian Fraß */ public function __construct( string $incident, array $details, int $timestamp ) { $this->incident = $incident; $this->details = $details; $this->timestamp = $timestamp; } } /** * @param string $incident * @param array $details * @author Christian Fraß */ function make( string $incident, array $details = [], int $timestamp = -1 ) : struct_report { if ($timestamp < 0) { $timestamp = time(); } return ( new struct_report( $incident, $details, $timestamp ) ); } /** * @param \alveolata\report\type $report * @return Exception * @author Christian Fraß */ function as_exception( struct_report $report ) : \Exception { $message = \alveolata\string\coin( '{{incident}} | {{details}}', [ 'incident' => $report->incident, 'details' => \alveolata\json\encode($report->details), ] ); return (new \Exception($message)); } ?>