Permalink
Browse files

Removed old school underscore prefix.

  • Loading branch information...
1 parent 0c7cb91 commit 18cce3839a3ba915584de1fb8765163b48240c21 @hype- hype- committed Jan 23, 2013
@@ -46,7 +46,7 @@ public function take($number)
{
$result = array();
if ($number > 0) {
- $result = array_slice($this->_elements, 0, $number, true);
+ $result = array_slice($this->elements, 0, $number, true);
}
return static::create($result);
}
@@ -56,16 +56,16 @@ public function take($number)
*/
public function rest()
{
- return static::create(array_slice($this->_elements, 1, null, true));
+ return static::create(array_slice($this->elements, 1, null, true));
}
public function filter($callback = null)
{
// Passing null to array_filter results in error, but omitting the second argument is ok.
$result = (null === $callback)
- ? array_filter($this->_elements)
+ ? array_filter($this->elements)
// array_filter only provides values; adding keys manually
- : array_filter($this->_elements, $this->addKeyArgument($callback));
+ : array_filter($this->elements, $this->addKeyArgument($callback));
return static::create($result);
}
@@ -103,7 +103,7 @@ public function map($callback)
{
// Providing keys to the callback manually, because index associations
// are not maintained when array_map is called with multiple arrays.
- return static::create(array_map($this->addKeyArgument($callback), $this->_elements));
+ return static::create(array_map($this->addKeyArgument($callback), $this->elements));
}
/**
@@ -122,7 +122,7 @@ public function map($callback)
*/
private function addKeyArgument($callback)
{
- $values = $this->_elements;
+ $values = $this->elements;
return function($value) use($callback, $values) {
list($key) = each($values);
return $callback($value, $key);
@@ -131,24 +131,24 @@ private function addKeyArgument($callback)
public function concatenate($other)
{
- $left = array_values($this->_elements);
+ $left = array_values($this->elements);
$right = array_values($other->toArray());
return static::create(array_merge($left, $right));
}
public function union($other)
{
- return static::create($other->toArray() + $this->_elements);
+ return static::create($other->toArray() + $this->elements);
}
public function values()
{
- return static::create(array_values($this->_elements));
+ return static::create(array_values($this->elements));
}
public function keys()
{
- return static::create(array_keys($this->_elements));
+ return static::create(array_keys($this->elements));
}
public function flatMap($callback)
@@ -185,7 +185,7 @@ public function unique($strict = true)
{
if (false === $strict) {
// array_unique can't check for strict uniqueness
- return static::create(array_unique($this->_elements, SORT_REGULAR));
+ return static::create(array_unique($this->elements, SORT_REGULAR));
}
return $this->apply(Functions::unique($strict));
}
@@ -205,7 +205,7 @@ public function sortBy($metric)
*/
public function reverse()
{
- return static::create(array_reverse($this->_elements));
+ return static::create(array_reverse($this->elements));
}
/**
@@ -214,7 +214,7 @@ public function reverse()
*/
public function merge(Collection $other)
{
- return static::create(array_merge($this->_elements, $other->toArray()));
+ return static::create(array_merge($this->elements, $other->toArray()));
}
/**
@@ -244,7 +244,7 @@ public function min()
);
}
- return min($this->_elements);
+ return min($this->elements);
}
/**
@@ -258,23 +258,23 @@ public function max()
);
}
- return max($this->_elements);
+ return max($this->elements);
}
/**
* {@inheritdoc}
*/
public function sum()
{
- return $this->isEmpty() ? 0 : array_sum($this->_elements);
+ return $this->isEmpty() ? 0 : array_sum($this->elements);
}
/**
* {@inheritdoc}
*/
public function product()
{
- return $this->isEmpty() ? 1 : array_product($this->_elements);
+ return $this->isEmpty() ? 1 : array_product($this->elements);
}
/**
@@ -13,36 +13,36 @@ class ArrayEnumerable implements Enumerable
/**
* @var array
*/
- protected $_elements;
+ protected $elements;
/**
* @param array $elements
*/
public function __construct($elements)
{
- $this->_elements = $elements;
+ $this->elements = $elements;
}
public function getIterator()
{
- return new \ArrayIterator($this->_elements);
+ return new \ArrayIterator($this->elements);
}
public function toArray()
{
- return $this->_elements;
+ return $this->elements;
}
public function each($callback, $userdata = null)
{
- array_walk($this->_elements, $callback, $userdata);
+ array_walk($this->elements, $callback, $userdata);
return $this;
}
public function reduce($callback, $initial = null)
{
$result = $initial;
- foreach ($this->_elements as $key => $value) {
+ foreach ($this->elements as $key => $value) {
$result = $callback($result, $value, $key);
}
return $result;
@@ -56,7 +56,7 @@ public function tap($callback)
public function exists($callback)
{
- foreach ($this->_elements as $value) {
+ foreach ($this->elements as $value) {
if ($callback($value)) {
return true;
}
@@ -66,7 +66,7 @@ public function exists($callback)
public function forAll($callback)
{
- foreach ($this->_elements as $value) {
+ foreach ($this->elements as $value) {
if (!$callback($value)) {
return false;
}
@@ -76,7 +76,7 @@ public function forAll($callback)
public function find($callback)
{
- foreach ($this->_elements as $value) {
+ foreach ($this->elements as $value) {
if ($callback($value)) {
return $value;
}
@@ -86,12 +86,12 @@ public function find($callback)
public function first()
{
- return reset($this->_elements);
+ return reset($this->elements);
}
public function last()
{
- return end($this->_elements);
+ return end($this->elements);
}
public function countAll($predicate)
@@ -107,6 +107,6 @@ public function countAll($predicate)
public function count()
{
- return count($this->_elements);
+ return count($this->elements);
}
-}
+}

0 comments on commit 18cce38

Please sign in to comment.