@@ 148-169 (lines=22) @@ | ||
145 | /** |
|
146 | * {@inheritdoc} |
|
147 | */ |
|
148 | public function expiresAt($expiration = null) |
|
149 | { |
|
150 | if ($expiration instanceof \DateTime) { |
|
151 | $this->expiration = $expiration; |
|
152 | ||
153 | } elseif (is_int($expiration)) { |
|
154 | $this->expiration = new \DateTime( |
|
155 | 'now +' . $expiration . ' seconds' |
|
156 | ); |
|
157 | ||
158 | } elseif (null === $expiration) { |
|
159 | $this->expiration = new \DateTime(self::DEFAULT_EXPIRATION); |
|
160 | ||
161 | } else { |
|
162 | ||
163 | throw new InvalidArgumentException( |
|
164 | 'Integer or \DateTime object expected.' |
|
165 | ); |
|
166 | } |
|
167 | ||
168 | return $this; |
|
169 | } |
|
170 | ||
171 | /** |
|
172 | * {@inheritdoc} |
|
@@ 174-194 (lines=21) @@ | ||
171 | /** |
|
172 | * {@inheritdoc} |
|
173 | */ |
|
174 | public function expiresAfter($time) |
|
175 | { |
|
176 | if ($time instanceof \DateInterval) { |
|
177 | $this->expiration = new \DateTime(); |
|
178 | $this->expiration->add($time); |
|
179 | ||
180 | } elseif (is_int($time)) { |
|
181 | $this->expiration = new \DateTime('now +' . $time . ' seconds'); |
|
182 | ||
183 | } elseif (null === $time) { |
|
184 | $this->expiration = new \DateTime(self::DEFAULT_EXPIRATION); |
|
185 | ||
186 | } else { |
|
187 | ||
188 | throw new InvalidArgumentException( |
|
189 | 'Integer or \DateInterval object expected.' |
|
190 | ); |
|
191 | } |
|
192 | ||
193 | return $this; |
|
194 | } |
|
195 | ||
196 | /** |
|
197 | * Returns the item value. |