Skip to content

Commit

Permalink
Calling unwrap() directly
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 10, 2015
1 parent d19485b commit fe03005
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/Collection/CollectionTrait.php
Expand Up @@ -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;
Expand All @@ -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);
}

/**
Expand All @@ -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);
});
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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);
}

/**
Expand All @@ -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;
Expand All @@ -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);
}

/**
Expand All @@ -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();
}

/**
Expand All @@ -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();
}

/**
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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();
});
Expand All @@ -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);
}

/**
Expand All @@ -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);
Expand Down

0 comments on commit fe03005

Please sign in to comment.