Files
apimacro/vendor/dragonmantank/cron-expression/src/Cron/FieldInterface.php

47 lines
1.3 KiB
PHP
Raw Normal View History

2024-05-07 12:17:25 +02:00
<?php
2024-08-13 13:44:16 +00:00
declare(strict_types=1);
2024-05-07 12:17:25 +02:00
namespace Cron;
use DateTimeInterface;
/**
2024-08-13 13:44:16 +00:00
* CRON field interface.
2024-05-07 12:17:25 +02:00
*/
interface FieldInterface
{
/**
2024-08-13 13:44:16 +00:00
* Check if the respective value of a DateTime field satisfies a CRON exp.
2024-05-07 12:17:25 +02:00
*
2024-08-13 13:44:16 +00:00
* @internal
2024-05-07 12:17:25 +02:00
* @param DateTimeInterface $date DateTime object to check
* @param string $value CRON expression to test against
*
* @return bool Returns TRUE if satisfied, FALSE otherwise
*/
2024-08-13 13:44:16 +00:00
public function isSatisfiedBy(DateTimeInterface $date, $value, bool $invert): bool;
2024-05-07 12:17:25 +02:00
/**
* When a CRON expression is not satisfied, this method is used to increment
2024-08-13 13:44:16 +00:00
* or decrement a DateTime object by the unit of the cron field.
2024-05-07 12:17:25 +02:00
*
2024-08-13 13:44:16 +00:00
* @internal
* @param DateTimeInterface $date DateTime object to change
* @param bool $invert (optional) Set to TRUE to decrement
* @param string|null $parts (optional) Set parts to use
2024-05-07 12:17:25 +02:00
*
* @return FieldInterface
*/
2024-08-13 13:44:16 +00:00
public function increment(DateTimeInterface &$date, $invert = false, $parts = null): FieldInterface;
2024-05-07 12:17:25 +02:00
/**
2024-08-13 13:44:16 +00:00
* Validates a CRON expression for a given field.
2024-05-07 12:17:25 +02:00
*
* @param string $value CRON expression value to validate
*
* @return bool Returns TRUE if valid, FALSE otherwise
*/
2024-08-13 13:44:16 +00:00
public function validate(string $value): bool;
2024-05-07 12:17:25 +02:00
}