Skip to content

Latest commit

 

History

History
68 lines (49 loc) · 3.61 KB

ReportObject.md

File metadata and controls

68 lines (49 loc) · 3.61 KB

Report Object

Getting a Report Object

The result of Stopwatch is a report that can be obtained in the object view by calling the getReport() method:

$stopwatch = new Almasmurad\Stopwatch\Stopwatch();

//... (measured code)

$report = $stopwatch->getReport();

The $report object provides access to the report components via methods:

method type description
getStart() EventInterface Stopwatch countdown beginning event
getFinish() EventInterface Stopwatch countdown end event
getPeriod() PeriodInterface The time elapsed from the beginning to the end of the countdown
getSteps() StepReportInterface[] The Reports of all steps of measurement
getStep()1 StepReportInterface The report of the step by its name
getStepByIndex()1 StepReportInterface The report of the step by its number
getNotices() string[] Notices list (see the chapter Notices)

Steps

The component of the StepReportInterface (\Almasmurad\Stopwatch\Report\Common\StepReportInterface) - a report one step taken that has the following methods:

метод тип описание
getName() string название этапа
getStart() EventInterface событие начала отсчёта этапа
getFinish() EventInterface событие конца отсчёта этапа
getPeriod() PeriodInterface время, прошедшее от начала до конца этапа

Events

The component of the EventInterface type (Almasmurad\Stopwatch\Time\Common\EventInterface) - an event that has the following methods:

method type description
getTimestamp() float The date of the event in Unix time format
getDateTime() DateTimeInterface The date of the event in the form of a DateTime object

Time Periods

The component of the PeriodInterface (Almasmurad\Stopwatch\Period\Common\PeriodInterface) - a time period that has the following method:

method type description
getSeconds() float number of seconds

Example of using a report object:

$report = $stopwatch->getReport();
$elapsed = $report->getPeriod()->getSeconds();
printf('Wow it spent %f seconds!', $elapsed);

Footnotes

  1. If a non-existent step number or a non-existent name is specified, the "null object" of StepReportInterface type is returned. To check whether the object is null, use the isNull() method. 2