public function setExpiryDate($time)
    {
        if ($time === null || $time === '') {
            $this->expiryDate = null;
            return $this;
        }

        if (is_string($time)) {
            try {
                $time = new DateTime($time);
            } catch (Exception $e) {
                throw new UnexpectedValueException(sprintf(
                    'Invalid Expiration Date: %s',
                    $e->getMessage()
                ), $e->getCode(), $e);
            }
        }

        if (!$time instanceof DateTimeInterface) {
            throw new InvalidArgumentException(
                'Expiration Date must be a date/time string or an instance of DateTimeInterface'
            );
        }

        $this->expiryDate = $time;

        return $this;
    }
public function setExpiryDate($time)
    {
        if ($time === null || $time === '') {
            $this->expiryDate = null;
            return $this;
        }

        if (is_string($time)) {
            try {
                $time = new DateTime($time);
            } catch (Exception $e) {
                throw new UnexpectedValueException(sprintf(
                    'Invalid Expiration Date: %s',
                    $e->getMessage()
                ), $e->getCode(), $e);
            }
        }

        if (!$time instanceof DateTimeInterface) {
            throw new InvalidArgumentException(
                'Expiration Date must be a date/time string or an instance of DateTimeInterface'
            );
        }

        $this->expiryDate = $time;

        return $this;
    }
public function setExpiryDate ( $ time ) { if ( $ time === null || $ time === '' ) { $ this -> expiryDate = null ; return $ this ; } if ( is_string ( $ time ) ) { try { $ time = new DateTime ( $ time ) ; } catch ( Exception $ e ) { throw new UnexpectedValueException ( sprintf ( 'Invalid Expiration Date: %s' , $ e -> getMessage ( ) ) , $ e -> getCode ( ) , $ e ) ; } } if ( ! $ time instanceof DateTimeInterface ) { throw new InvalidArgumentException ( 'Expiration Date must be a date/time string or an instance of DateTimeInterface' ) ; } $ this -> expiryDate = $ time ; return $ this ; }
Set the object's expiration date.

@param  string|DateTimeInterface|null $time The date/time value.
@throws UnexpectedValueException If the date/time value is invalid.
@throws InvalidArgumentException If the value is not a date/time instance.
@return PublishableInterface Chainable
Set the object s expiration date .