MatthiasMullie\Scrapbook\Psr6\Item::expiresAt PHP Method

expiresAt() public method

public expiresAt ( $expiration )
    public function expiresAt($expiration)
    {
        // DateTimeInterface only exists since PHP>=5.5, also accept DateTime
        if ($expiration instanceof DateTimeInterface || $expiration instanceof DateTime) {
            // convert datetime to unix timestamp
            $this->expire = (int) $expiration->format('U');
            $this->changed = true;
        } elseif ($expiration === null) {
            $this->expire = 0;
            $this->changed = true;
        } else {
            $class = get_class($this);
            $type = gettype($expiration);
            $error = "Argument 1 passed to {$class}::expiresAt()  must be an " . "instance of DateTime or DateTimeImmutable, {$type} given";
            if (class_exists('\\TypeError')) {
                throw new \TypeError($error);
            }
            trigger_error($error, E_USER_ERROR);
        }
        return $this;
    }