/**
* @throws InvalidArgumentException
* @throws UnexpectedValueException
*/
public function denormalize(mixed
$data, string
$type, string
$format = null, array
$context =
[]): \DateInterval
{ if (!\
is_string($data)) { throw new InvalidArgumentException(sprintf('Data expected to be a string, "%s" given.',
get_debug_type($data)));
} if (!
$this->
isISO8601($data)) { throw new UnexpectedValueException('Expected a valid ISO 8601 interval string.'
);
} $dateIntervalFormat =
$context[self::FORMAT_KEY
] ??
$this->defaultContext
[self::FORMAT_KEY
];
$signPattern = '';
switch (substr($dateIntervalFormat, 0, 2
)) { case '%R':
$signPattern = '[-+]';
$dateIntervalFormat =
substr($dateIntervalFormat, 2
);
break;