Skip to content

Commit d16d8e4

Browse files
author
Bulat Shakirzyanov
committed
ensure the last page returns null
1 parent e94e7c2 commit d16d8e4

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/Cassandra/FutureValue.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2015 DataStax, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
namespace Cassandra;
20+
21+
/**
22+
* A future that always resolves in a value.
23+
*/
24+
final class FutureValue implements Future
25+
{
26+
/**
27+
* Actual value to resolve this future with.
28+
*
29+
* @var mixed
30+
*/
31+
private $value;
32+
33+
/**
34+
* Creates a future value.
35+
*
36+
* @param mixed $value a value to resolve this future with.
37+
*/
38+
public function __construct($value)
39+
{
40+
$this->value = $value;
41+
}
42+
43+
/**
44+
* {@inheritDoc}
45+
*/
46+
public function get($timeout = null)
47+
{
48+
return $this->value;
49+
}
50+
}

src/Cassandra/Rows.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ public function nextPage($timeout = null)
198198
*/
199199
public function nextPageAsync()
200200
{
201+
if (isLastPage()) {
202+
return new FutureValue(null);
203+
}
204+
201205
try {
202206
cassandra_statement_set_paging_state($this->statement, $this->resource);
203207
} catch (Exception $e) {

0 commit comments

Comments
 (0)