Browse Source

Calling unwrap() directly

Jose Lorenzo Rodriguez 11 years ago
parent
commit
fe030056d0
1 changed files with 19 additions and 19 deletions
  1. 19 19
      src/Collection/CollectionTrait.php

+ 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 @@ trait CollectionTrait
                 return (bool)$v;
             };
         }
-        return new FilterIterator($this->_unwrap(), $c);
+        return new FilterIterator($this->unwrap(), $c);
     }
 
     /**
@@ -74,7 +74,7 @@ trait CollectionTrait
      */
     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 @@ trait CollectionTrait
      */
     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 @@ trait CollectionTrait
      */
     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 @@ trait CollectionTrait
      */
     public function contains($value)
     {
-        foreach ($this->_unwrap() as $v) {
+        foreach ($this->unwrap() as $v) {
             if ($value === $v) {
                 return true;
             }
@@ -128,7 +128,7 @@ trait CollectionTrait
      */
     public function map(callable $c)
     {
-        return new ReplaceIterator($this->_unwrap(), $c);
+        return new ReplaceIterator($this->unwrap(), $c);
     }
 
     /**
@@ -143,7 +143,7 @@ trait CollectionTrait
         }
 
         $result = $zero;
-        foreach ($this->_unwrap() as $k => $value) {
+        foreach ($this->unwrap() as $k => $value) {
             if ($isFirst) {
                 $result = $value;
                 $isFirst = false;
@@ -161,7 +161,7 @@ trait CollectionTrait
      */
     public function extract($matcher)
     {
-        return new ExtractIterator($this->_unwrap(), $matcher);
+        return new ExtractIterator($this->unwrap(), $matcher);
     }
 
     /**
@@ -170,7 +170,7 @@ trait CollectionTrait
      */
     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 @@ trait CollectionTrait
      */
     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 @@ trait CollectionTrait
      */
     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 @@ trait CollectionTrait
         $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 @@ trait CollectionTrait
      */
     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 @@ trait CollectionTrait
     {
         $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 @@ trait CollectionTrait
             $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 @@ trait CollectionTrait
             $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 @@ trait CollectionTrait
      */
     public function insert($path, $values)
     {
-        return new InsertIterator($this->_unwrap(), $path, $values);
+        return new InsertIterator($this->unwrap(), $path, $values);
     }
 
     /**
@@ -423,7 +423,7 @@ trait CollectionTrait
      */
     public function toArray($preserveKeys = true)
     {
-        $iterator = $this->_unwrap();
+        $iterator = $this->unwrap();
         if ($iterator instanceof ArrayIterator) {
             $items = $iterator->getArrayCopy();
             return $preserveKeys ? $items : array_values($items);