Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DateCaster.php

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\Caster

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal