PeriodicalTrigger example

// test that we are using the fast algorithm for short period of time             $p = new \ReflectionProperty($trigger, 'intervalInSeconds');
            $this->assertNotSame(0, $p->getValue($trigger));
        }
    }

    public static function provideForConstructor(): iterable
    {
        $from = new \DateTimeImmutable($now = '2022-02-22 13:34:00+01:00');
        $until = new \DateTimeImmutable($farFuture = '3000-01-01');

        yield [new PeriodicalTrigger(86400, $from$until)];
        yield [new PeriodicalTrigger('86400', $from$until)];
        yield [new PeriodicalTrigger('1 day', $from$until), false];
        yield [new PeriodicalTrigger('24 hours', $from$until)];
        yield [new PeriodicalTrigger('1440 minutes', $from$until)];
        yield [new PeriodicalTrigger('86400 seconds', $from$until)];
        yield [new PeriodicalTrigger('1day', $from$until), false];
        yield [new PeriodicalTrigger('24hours', $from$until)];
        yield [new PeriodicalTrigger('1440minutes', $from$until)];
        yield [new PeriodicalTrigger('86400seconds', $from$until)];
        yield [new PeriodicalTrigger('P1D', $from$until), false];
        yield [new PeriodicalTrigger('PT24H', $from$until)];
        

    public static function every(string|int|\DateInterval $frequency, object $message, string|\DateTimeImmutable $from = null, string|\DateTimeImmutable $until = new \DateTimeImmutable('3000-01-01')): self
    {
        return self::trigger(new PeriodicalTrigger($frequency$from$until)$message);
    }

    /** * @param MessageProviderInterface|object $message A message provider that yields messages or a static message that will be dispatched on every trigger */
    public static function cron(string $expression, object $message, \DateTimeZone|string $timezone = null): self
    {
        if (!str_contains($expression, '#')) {
            return self::trigger(CronExpressionTrigger::fromSpec($expression, null, $timezone)$message);
        }

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