StopwatchPeriod example

use PHPUnit\Framework\TestCase;
use Symfony\Component\Stopwatch\StopwatchPeriod;

class StopwatchPeriodTest extends TestCase
{
    /** * @dataProvider provideTimeValues */
    public function testGetStartTime($start$useMorePrecision$expected)
    {
        $period = new StopwatchPeriod($start$start$useMorePrecision);
        $this->assertSame($expected$period->getStartTime());
    }

    /** * @dataProvider provideTimeValues */
    public function testGetEndTime($end$useMorePrecision$expected)
    {
        $period = new StopwatchPeriod($end$end$useMorePrecision);
        $this->assertSame($expected$period->getEndTime());
    }

    

    public function stop()static
    {
        if (!\count($this->started)) {
            throw new \LogicException('stop() called but start() has not been called before.');
        }

        $this->periods[] = new StopwatchPeriod(array_pop($this->started)$this->getNow()$this->morePrecision);

        return $this;
    }

    /** * Checks if the event was started. */
    public function isStarted(): bool
    {
        return !empty($this->started);
    }

    
Home | Imprint | This part of the site doesn't use cookies.