function Matches::map
Replaces all the matches with the result of the given function. The function will receive the node and its parent as arguments and must return an array of matches
Parameters
callable $fn Map function:
Return value
$this
File
-
vendor/
mck89/ peast/ lib/ Peast/ Selector/ Matches.php, line 99
Class
- Matches
- Selector matches class
Namespace
Peast\SelectorCode
public function map(callable $fn) {
$newMatches = array();
foreach ($this->matches as $match) {
$res = $fn($match[0], $match[1]);
if ($res) {
$newMatches = array_merge($newMatches, $res);
}
}
$this->matches = $newMatches;
return $this->unique();
}