1<?php
2
3namespace DeepCopy\TypeFilter\Date;
4
5use DateInterval;
6use DeepCopy\TypeFilter\TypeFilter;
7
8/**
9 * @final
10 *
11 * @deprecated Will be removed in 2.0. This filter will no longer be necessary in PHP 7.1+.
12 */
13class DateIntervalFilter implements TypeFilter
14{
15
16    /**
17     * {@inheritdoc}
18     *
19     * @param DateInterval $element
20     *
21     * @see http://news.php.net/php.bugs/205076
22     */
23    public function apply($element)
24    {
25        $copy = new DateInterval('P0D');
26
27        foreach ($element as $propertyName => $propertyValue) {
28            $copy->{$propertyName} = $propertyValue;
29        }
30
31        return $copy;
32    }
33}
34