function DateCaster::castInterval
File
-
vendor/
symfony/ var-dumper/ Caster/ DateCaster.php, line 50
Class
- DateCaster
- Casts DateTimeInterface related classes to array representation.
Namespace
Symfony\Component\VarDumper\CasterCode
public static function castInterval(\DateInterval $interval, array $a, Stub $stub, bool $isNested, int $filter) : array {
$now = new \DateTimeImmutable('@0', new \DateTimeZone('UTC'));
$numberOfSeconds = $now->add($interval)
->getTimestamp() - $now->getTimestamp();
$title = number_format($numberOfSeconds, 0, '.', ' ') . 's';
$i = [
Caster::PREFIX_VIRTUAL . 'interval' => new ConstStub(self::formatInterval($interval), $title),
];
return $filter & Caster::EXCLUDE_VERBOSE ? $i : $i + $a;
}