lliure / reattempts
此包旨在生成在规定时间内自动测试持久性的查询/咨询。
v1.2.1
2024-05-28 21:39 UTC
Requires
- php: >=7.2 || ^8.0
This package is auto-updated.
Last update: 2024-08-28 22:06:56 UTC
README
该类旨在生成一个用于在规定时间内测试持久性的自动where查询。
开始使用
$reattempt = new Reattempts();
$reattempt->setAttemptsDefault(5);
$reattempt->addInterval('PT5H');
$reattempt->addInterval('PT12H');
$reattempt->addInterval('P1D');
$whereReattempt = $reattempt->generateWhereQuery('attempts', 'createdAt');
上面的示例将生成一个用于在指定范围内的查询的where。
setAttemptsDefault(5)
定义将进行5次默认尝试addInterval('PT1H')
定义下一次尝试的间隔为5小时addInterval('PT12H')
定义下一次尝试的间隔为12小时*addInterval('P1D')
定义下一次尝试的间隔为1天
定义间隔使用的是 dateinterval 语法
类摘要
class Reattempts(){
public function __construct(int $attemptsDefault = 4)
public function setAttemptsDefault(int $attemptsDefault): void
public function addInterval(string $interval): void
public function nextInterval(string $interval, int $repeat = 1): void
public function generateWhereQuery(string $columnAttempts = 'attempts', string $columnInsertedAt = 'insertedAt'): string
public function __toString(): string
}
方法
public function __construct(int $attemptsDefault = 4)
构建对象
public function setAttemptsDefault(int $attemptsDefault): void
配置尝试次数
public function addInterval(string $interval): void
添加一个基于当前时间的间隔
public function nextInterval(string $interval, int $repeat = 1): void
添加一个基于前一个间隔的间隔。重复此过程可以添加具有相同配置的更多间隔。
public function generateWhereQuery(string $columnAttempts = 'attempts', string $columnInsertedAt = 'insertedAt'): string
返回生成的查询
public function __toString(): string
返回使用默认配置生成的查询