2022-07-05 15:55:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace DNW\Skills\FactorGraphs;
|
2016-05-24 14:10:39 +02:00
|
|
|
|
|
|
|
class ScheduleLoop extends Schedule
|
|
|
|
{
|
2023-08-02 09:15:01 +00:00
|
|
|
public function __construct($name, private readonly Schedule $scheduleToLoop, private $maxDelta)
|
2016-05-24 14:10:39 +02:00
|
|
|
{
|
|
|
|
parent::__construct($name);
|
|
|
|
}
|
|
|
|
|
2023-08-01 12:13:24 +00:00
|
|
|
public function visit(int $depth = -1, int $maxDepth = 0)
|
2016-05-24 14:10:39 +02:00
|
|
|
{
|
|
|
|
$totalIterations = 1;
|
2023-08-02 09:15:01 +00:00
|
|
|
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
|
|
|
|
while ($delta > $this->maxDelta) {
|
|
|
|
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
|
2016-05-24 14:10:39 +02:00
|
|
|
$totalIterations++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $delta;
|
|
|
|
}
|
2022-07-05 15:55:47 +02:00
|
|
|
}
|