本文整理匯總了PHP中IteratorIterator::valid方法的典型用法代碼示例。如果您正苦於以下問題:PHP IteratorIterator::valid方法的具體用法?PHP IteratorIterator::valid怎麽用?PHP IteratorIterator::valid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IteratorIterator
的用法示例。
在下文中一共展示了IteratorIterator::valid方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: valid
public function valid()
{
if (!parent::valid()) {
return false;
}
return $this->range->contains($this->current()->getKey());
}
示例2: next
public function next()
{
$this->chunk = array();
for ($i = 0; $i < $this->chunkSize && parent::valid(); $i++) {
$this->chunk[] = parent::current();
parent::next();
}
}
示例3: next
public function next()
{
$this->chunk = array();
for ($i = 0; $i < $this->size && parent::valid(); ++$i) {
$this->chunk[] = parent::current();
parent::next();
}
$this->chunk ? $this->key++ : null;
}
示例4: findChangelog
/**
* @param \nochso\WriteMe\Document $document
*
* @return \SplFileInfo
*/
private function findChangelog(Document $document)
{
$changelogName = $this->options->getValue('changelog.file');
$searchDepth = $this->options->getValue('changelog.search-depth');
$folder = dirname($document->getFilepath());
$files = new \IteratorIterator(Finder::findFiles($changelogName)->from($folder)->limitDepth($searchDepth));
$files->next();
if (!$files->valid()) {
throw new \RuntimeException(sprintf("Unable to find changelog '%s' in folder '%s'", $changelogName, $folder));
}
return $files->current();
}
示例5: valid
public function valid()
{
if (!parent::valid()) {
return false;
}
if ($aKey = FsKey::createKey(parent::current())) {
$this->aCurrentKey = $aKey;
return true;
} else {
return false;
}
}
示例6: getNextBunch
/**
* Get next bunch of validated rows.
*
* @return array|null
*/
public function getNextBunch()
{
if (null === $this->_iterator) {
$this->_iterator = $this->getIterator();
$this->_iterator->rewind();
}
if ($this->_iterator->valid()) {
$dataRow = $this->_iterator->current();
$dataRow = Mage::helper('core')->jsonDecode($dataRow[0]);
$this->_iterator->next();
} else {
$this->_iterator = null;
$dataRow = null;
}
return $dataRow;
}
示例7: getNextBunch
/**
* Get next bunch of validatetd rows.
*
* @return array|null
*/
public function getNextBunch()
{
if (null === $this->_iterator) {
$this->_iterator = $this->getIterator();
$this->_iterator->rewind();
}
if ($this->_iterator->valid()) {
$dataRow = $this->_iterator->current();
$dataRow = unserialize($dataRow[0]);
$this->_iterator->next();
} else {
$this->_iterator = null;
$dataRow = null;
}
return $dataRow;
}
示例8: valid
/**
* Returns whether the current element is valid or not (as required by the
* Iterator interface).
*
* @return bool true if the current element is valid; false otherwise
*/
public function valid()
{
return $this->iterator->valid();
}
示例9: valid
public function valid()
{
echo $this->key . ') ' . __METHOD__ . PHP_EOL;
return parent::valid();
}
示例10: valid
public function valid()
{
return parent::valid() && $this->it2->valid();
}
示例11: __construct
{
echo __METHOD__ . "({$name})\n";
}
}
$stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test', array('WOW'));
$it = new IteratorIterator($stmt);
/* check if we can convert that thing */
/*** HINT: If YOU plan to do so remember not to call rewind() -> see below ***/
foreach ($it as $data) {
var_dump($data);
}
$it->next();
/* must be allowed */
var_dump($it->current());
/* must return NULL */
var_dump($it->valid());
/* must return false */
class PDOStatementAggregate extends PDOStatement implements IteratorAggregate
{
private function __construct()
{
echo __METHOD__ . "\n";
$this->setFetchMode(PDO::FETCH_NUM);
/* default fetch mode is BOTH, so we see if the ctor can overwrite that */
}
function getIterator()
{
echo __METHOD__ . "\n";
$this->execute();
return new IteratorIterator($this, 'PDOStatement');
}
示例12: valid
/**
* Returns whether the iterator currently has a valid value
*
* @return Boolean
*/
public function valid()
{
$this->dumpStart(__FUNCTION__);
$result = parent::valid();
$this->dumpEnd(__FUNCTION__, $result);
return $result;
}
示例13: next
/**
* Move to next element
*/
public function next()
{
parent::next();
++$this->count;
if (parent::valid()) {
$this->advanceWindow();
}
}