You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
639 B
34 lines
639 B
3 years ago
|
<?php
|
||
|
|
||
|
namespace DeepCopy\TypeFilter\Date;
|
||
|
|
||
|
use DateInterval;
|
||
|
use DeepCopy\TypeFilter\TypeFilter;
|
||
|
|
||
|
/**
|
||
|
* @final
|
||
|
*
|
||
|
* @deprecated Will be removed in 2.0. This filter will no longer be necessary in PHP 7.1+.
|
||
|
*/
|
||
|
class DateIntervalFilter implements TypeFilter
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*
|
||
|
* @param DateInterval $element
|
||
|
*
|
||
|
* @see http://news.php.net/php.bugs/205076
|
||
|
*/
|
||
|
public function apply($element)
|
||
|
{
|
||
|
$copy = new DateInterval('P0D');
|
||
|
|
||
|
foreach ($element as $propertyName => $propertyValue) {
|
||
|
$copy->{$propertyName} = $propertyValue;
|
||
|
}
|
||
|
|
||
|
return $copy;
|
||
|
}
|
||
|
}
|