Skip to content
This repository has been archived by the owner on Jun 20, 2018. It is now read-only.

Commit

Permalink
Merge pull request #16 from kieranajp/hotfix/each-with-key
Browse files Browse the repository at this point in the history
Extract each out so we can each with key
  • Loading branch information
italolelis authored Dec 13, 2016
2 parents 7c987dc + 6ac809e commit c12e320
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/Traits/CommonContainerMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,6 @@ public function last()
return current($lastItem);
}

/**
* {@inheritDoc}
* @return $this
*/
public function each(callable $callable)
{
foreach ($this as $v) {
$callable($v);
}

return $this;
}

/**
* {@inheritdoc}
*/
Expand Down
13 changes: 13 additions & 0 deletions src/Traits/ConstMapLikeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,17 @@ public function toArray()

return $arr;
}

/**
* {@inheritDoc}
* @return $this
*/
public function each(callable $callable)
{
foreach ($this as $k => $v) {
$callable($v, $k);
}

return $this;
}
}
13 changes: 13 additions & 0 deletions src/Traits/ConstVectorLikeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,17 @@ public function toArray()

return $arr;
}

/**
* {@inheritDoc}
* @return $this
*/
public function each(callable $callable)
{
foreach ($this as $v) {
$callable($v);
}

return $this;
}
}
13 changes: 13 additions & 0 deletions src/Traits/MapLikeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,17 @@ public function remove($element)

return $this;
}

/**
* {@inheritDoc}
* @return $this
*/
public function each(callable $callable)
{
foreach ($this as $k => $v) {
$callable($v, $k);
}

return $this;
}
}
13 changes: 13 additions & 0 deletions src/Traits/SetLikeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,17 @@ public function removeAll($traversable)

return $this;
}

/**
* {@inheritDoc}
* @return $this
*/
public function each(callable $callable)
{
foreach ($this as $v) {
$callable($v);
}

return $this;
}
}
13 changes: 13 additions & 0 deletions src/Traits/VectorLikeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,17 @@ public function splice($offset, $length = null)
// $this->hacklib_expireAllIterators();
// }
}

/**
* {@inheritDoc}
* @return $this
*/
public function each(callable $callable)
{
foreach ($this as $v) {
$callable($v);
}

return $this;
}
}

0 comments on commit c12e320

Please sign in to comment.