Skip to content

Commit

Permalink
apply fabbpot.io patch
Browse files Browse the repository at this point in the history
  • Loading branch information
oneNevan committed Nov 17, 2023
1 parent b0eb741 commit 7744b34
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public function __construct(array $defaultContext = [])
}

/**
* {@inheritdoc}
*
* @return string
*
* @throws InvalidArgumentException
Expand All @@ -49,25 +47,17 @@ public function normalize($object, string $format = null, array $context = [])
return $object->format($context[self::FORMAT_KEY] ?? $this->defaultContext[self::FORMAT_KEY]);
}

/**
* {@inheritdoc}
*/
public function supportsNormalization($data, string $format = null)
{
return $data instanceof \DateInterval;
}

/**
* {@inheritdoc}
*/
public function hasCacheableSupportsMethod(): bool
{
return __CLASS__ === static::class;
}

/**
* {@inheritdoc}
*
* @return \DateInterval
*
* @throws NotNormalizableValueException
Expand Down Expand Up @@ -118,17 +108,14 @@ public function denormalize($data, string $type, string $format = null, array $c
}
}

/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, string $type, string $format = null)
{
return \DateInterval::class === $type;
}

private function isISO8601(string $string): bool
{
if (PHP_VERSION_ID >= 80000) {
if (\PHP_VERSION_ID >= 80000) {
return preg_match('/^[\-+]?P(?=\w*(?:\d|%\w))(?:\d+Y|%[yY]Y)?(?:\d+M|%[mM]M)?(?:\d+W|%[wW]W)?(?:\d+D|%[dD]D)?(?:T(?:\d+H|[hH]H)?(?:\d+M|[iI]M)?(?:\d+S|[sS]S)?)?$/', $string);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public function testDenormalizeIntervalsWithOmittedPartsBeingZero()
* Since PHP 8.0 DateInterval::construct supports periods containing both D and W period designators.
*
* @requires PHP 8
*
* @testWith ["%rP%yY%mM%wW%dDT%hH%iM%sS","P3W2D", 23]
*/
public function testDenormalizeIntervalWithBothWeeksAndDays(string $format, string $input, int $expectedDays)
Expand Down

0 comments on commit 7744b34

Please sign in to comment.