🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano
Beispiele
Retry mit virtuellem Schlaf
$clock = MockClock::from('2026-01-01 00:00:00', 'UTC');
$attempts = 0;
while ($attempts < 5) {
if ($api->try()) {
break;
}
++$attempts;
$clock->sleep(2 ** $attempts); // im Test sofort
}
Cache-Schlüssel pro Minute
$byMinute = TruncatingClock::toMinute(SystemClock::utc());
$key = 'rates:' . $byMinute->timestamp();
Ereignisserie im Test
$clock = StepClock::from('2026-01-01 00:00:00', TimeSpan::ofMinutes(5), 'UTC');
foreach ($batch as $message) {
$log->record($message, $clock->now()); // 00:00, 00:05, 00:10...
}
Messung von Etappen
$watch = Stopwatch::start();
$loader->import();
$watch->lap('import');
$indexer->rebuild();
$watch->lap('index');
$metrics->timing('job.total', $watch->stop());
Bereichsbezogene Zeit-Ersetzung
$report = ClockHolder::within(
FrozenClock::from('2026-03-31 23:59:59', 'UTC'),
fn () => $builder->quarterReport(),
);
🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano