Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #121 from doctrine/reorder-methods
Browse files Browse the repository at this point in the history
Reorder methods alphabetically
  • Loading branch information
jmikola committed Aug 5, 2013
2 parents 114a0ae + 368c49b commit 3876a2a
Show file tree
Hide file tree
Showing 18 changed files with 2,566 additions and 2,567 deletions.
102 changes: 51 additions & 51 deletions lib/Doctrine/MongoDB/ArrayIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,81 +45,87 @@ public function __construct(array $elements = array())
}

/**
* Return the first element in the array, or false if the array is empty.
*
* @see http://php.net/manual/en/function.reset.php
* @return array|object|boolean
* @see http://php.net/manual/en/countable.count.php
*/
public function first()
public function count()
{
return reset($this->elements);
return count($this->elements);
}

/**
* Return the last element in the array, or false if the array is empty.
*
* @see http://php.net/manual/en/function.end.php
* @return array|object|boolean
* @see http://php.net/manual/en/iterator.current.php
*/
public function last()
public function current()
{
return end($this->elements);
return current($this->elements);
}

/**
* @see http://php.net/manual/en/iterator.key.php
* Return the first element in the array, or false if the array is empty.
*
* @see http://php.net/manual/en/function.reset.php
* @return array|object|boolean
*/
public function key()
public function first()
{
return key($this->elements);
return reset($this->elements);
}

/**
* @see http://php.net/manual/en/iterator.next.php
* @see Iterator::getSingleResult()
*/
public function next()
public function getSingleResult()
{
next($this->elements);
$result = null;
$this->valid() ?: $this->next();
if ($this->valid()) {
$result = $this->current();
}
$this->reset();
return $result ? $result : null;
}

/**
* @see http://php.net/manual/en/iterator.current.php
* @see http://php.net/manual/en/iterator.key.php
*/
public function current()
public function key()
{
return current($this->elements);
return key($this->elements);
}

/**
* @see http://php.net/manual/en/countable.count.php
* Return the last element in the array, or false if the array is empty.
*
* @see http://php.net/manual/en/function.end.php
* @return array|object|boolean
*/
public function count()
public function last()
{
return count($this->elements);
return end($this->elements);
}

/**
* @see http://php.net/manual/en/iterator.rewind.php
* @see http://php.net/manual/en/iterator.next.php
*/
public function rewind()
public function next()
{
reset($this->elements);
next($this->elements);
}

/**
* Alias of {@link ArrayIterator::rewind()}.
* @see http://php.net/manual/en/arrayaccess.offsetexists.php
*/
public function reset()
public function offsetExists($offset)
{
reset($this->elements);
return isset($this->elements[$offset]);
}

/**
* @see http://php.net/manual/en/iterator.valid.php
* @see http://php.net/manual/en/arrayaccess.offsetget.php
*/
public function valid()
public function offsetGet($offset)
{
return current($this->elements) !== false;
return isset($this->elements[$offset]) ? $this->elements[$offset] : null;
}

/**
Expand All @@ -131,27 +137,27 @@ public function offsetSet($offset, $value)
}

/**
* @see http://php.net/manual/en/arrayaccess.offsetexists.php
* @see http://php.net/manual/en/arrayaccess.offsetunset.php
*/
public function offsetExists($offset)
public function offsetUnset($offset)
{
return isset($this->elements[$offset]);
unset($this->elements[$offset]);
}

/**
* @see http://php.net/manual/en/arrayaccess.offsetunset.php
* Alias of {@link ArrayIterator::rewind()}.
*/
public function offsetUnset($offset)
public function reset()
{
unset($this->elements[$offset]);
reset($this->elements);
}

/**
* @see http://php.net/manual/en/arrayaccess.offsetget.php
* @see http://php.net/manual/en/iterator.rewind.php
*/
public function offsetGet($offset)
public function rewind()
{
return isset($this->elements[$offset]) ? $this->elements[$offset] : null;
reset($this->elements);
}

/**
Expand All @@ -163,16 +169,10 @@ public function toArray()
}

/**
* @see Iterator::getSingleResult()
* @see http://php.net/manual/en/iterator.valid.php
*/
public function getSingleResult()
public function valid()
{
$result = null;
$this->valid() ?: $this->next();
if ($this->valid()) {
$result = $this->current();
}
$this->reset();
return $result ? $result : null;
return current($this->elements) !== false;
}
}
Loading

0 comments on commit 3876a2a

Please sign in to comment.