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
|
|
|
|
{
|
2022-07-05 16:21:06 +02: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;
|
|
|
|
$delta = $this->_scheduleToLoop->visit($depth + 1, $maxDepth);
|
|
|
|
while ($delta > $this->_maxDelta) {
|
|
|
|
$delta = $this->_scheduleToLoop->visit($depth + 1, $maxDepth);
|
|
|
|
$totalIterations++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $delta;
|
|
|
|
}
|
2022-07-05 15:55:47 +02:00
|
|
|
}
|