Skip to content
Permalink
Browse files

Calling unwrap() directly

  • Loading branch information...
lorenzo committed May 10, 2015
1 parent d19485b commit fe030056d0abf0408b64f9b1dd692b4247a67652
Showing with 19 additions and 19 deletions.
  1. +19 −19 src/Collection/CollectionTrait.php
@@ -46,7 +46,7 @@ trait CollectionTrait
*/
public function each(callable $c)
{
foreach ($this->_unwrap() as $k => $v) {
foreach ($this->unwrap() as $k => $v) {
$c($v, $k);
}
return $this;
@@ -64,7 +64,7 @@ public function filter(callable $c = null)
return (bool)$v;
};
}
return new FilterIterator($this->_unwrap(), $c);
return new FilterIterator($this->unwrap(), $c);
}
/**
@@ -74,7 +74,7 @@ public function filter(callable $c = null)
*/
public function reject(callable $c)
{
return new FilterIterator($this->_unwrap(), function ($key, $value, $items) use ($c) {
return new FilterIterator($this->unwrap(), function ($key, $value, $items) use ($c) {
return !$c($key, $value, $items);
});
}
@@ -85,7 +85,7 @@ public function reject(callable $c)
*/
public function every(callable $c)
{
foreach ($this->_unwrap() as $key => $value) {
foreach ($this->unwrap() as $key => $value) {
if (!$c($value, $key)) {
return false;
}
@@ -99,7 +99,7 @@ public function every(callable $c)
*/
public function some(callable $c)
{
foreach ($this->_unwrap() as $key => $value) {
foreach ($this->unwrap() as $key => $value) {
if ($c($value, $key) === true) {
return true;
}
@@ -113,7 +113,7 @@ public function some(callable $c)
*/
public function contains($value)
{
foreach ($this->_unwrap() as $v) {
foreach ($this->unwrap() as $v) {
if ($value === $v) {
return true;
}
@@ -128,7 +128,7 @@ public function contains($value)
*/
public function map(callable $c)
{
return new ReplaceIterator($this->_unwrap(), $c);
return new ReplaceIterator($this->unwrap(), $c);
}
/**
@@ -143,7 +143,7 @@ public function reduce(callable $c, $zero = null)
}
$result = $zero;
foreach ($this->_unwrap() as $k => $value) {
foreach ($this->unwrap() as $k => $value) {
if ($isFirst) {
$result = $value;
$isFirst = false;
@@ -161,7 +161,7 @@ public function reduce(callable $c, $zero = null)
*/
public function extract($matcher)
{
return new ExtractIterator($this->_unwrap(), $matcher);
return new ExtractIterator($this->unwrap(), $matcher);
}
/**
@@ -170,7 +170,7 @@ public function extract($matcher)
*/
public function max($callback, $type = SORT_NUMERIC)
{
return (new SortIterator($this->_unwrap(), $callback, SORT_DESC, $type))->first();
return (new SortIterator($this->unwrap(), $callback, SORT_DESC, $type))->first();
}
/**
@@ -179,7 +179,7 @@ public function max($callback, $type = SORT_NUMERIC)
*/
public function min($callback, $type = SORT_NUMERIC)
{
return (new SortIterator($this->_unwrap(), $callback, SORT_ASC, $type))->first();
return (new SortIterator($this->unwrap(), $callback, SORT_ASC, $type))->first();
}
/**
@@ -188,7 +188,7 @@ public function min($callback, $type = SORT_NUMERIC)
*/
public function sortBy($callback, $dir = SORT_DESC, $type = SORT_NUMERIC)
{
return new SortIterator($this->_unwrap(), $callback, $dir, $type);
return new SortIterator($this->unwrap(), $callback, $dir, $type);
}
/**
@@ -234,7 +234,7 @@ public function countBy($callback)
$reducer = function ($values, $key, $mr) {
$mr->emit(count($values), $key);
};
return new Collection(new MapReduce($this->_unwrap(), $mapper, $reducer));
return new Collection(new MapReduce($this->unwrap(), $mapper, $reducer));
}
/**
@@ -278,7 +278,7 @@ public function sample($size = 10)
*/
public function take($size = 1, $from = 0)
{
return new Collection(new LimitIterator($this->_unwrap(), $from, $size));
return new Collection(new LimitIterator($this->unwrap(), $from, $size));
}
/**
@@ -318,7 +318,7 @@ public function append($items)
{
$list = new AppendIterator;
$list->append($this);
$list->append((new Collection($items))->_unwrap());
$list->append((new Collection($items))->unwrap());
return new Collection($list);
}
@@ -358,7 +358,7 @@ public function combine($keyPath, $valuePath, $groupPath = null)
$mapReduce->emit($result, $key);
};
return new Collection(new MapReduce($this->_unwrap(), $mapper, $reducer));
return new Collection(new MapReduce($this->unwrap(), $mapper, $reducer));
}
/**
@@ -401,7 +401,7 @@ public function nest($idPath, $parentPath)
$parents[$key]['children'] = $children;
};
return (new Collection(new MapReduce($this->_unwrap(), $mapper, $reducer)))
return (new Collection(new MapReduce($this->unwrap(), $mapper, $reducer)))
->map(function ($value) use (&$isObject) {
return $isObject ? $value : $value->getArrayCopy();
});
@@ -414,7 +414,7 @@ public function nest($idPath, $parentPath)
*/
public function insert($path, $values)
{
return new InsertIterator($this->_unwrap(), $path, $values);
return new InsertIterator($this->unwrap(), $path, $values);
}
/**
@@ -423,7 +423,7 @@ public function insert($path, $values)
*/
public function toArray($preserveKeys = true)
{
$iterator = $this->_unwrap();
$iterator = $this->unwrap();
if ($iterator instanceof ArrayIterator) {
$items = $iterator->getArrayCopy();
return $preserveKeys ? $items : array_values($items);

0 comments on commit fe03005

Please sign in to comment.
You can’t perform that action at this time.