This commit is contained in:
2023-04-25 18:09:41 +00:00
parent 7b2f03e139
commit c2f00d6c21
6 changed files with 118 additions and 74 deletions
+5 -7
View File
@@ -26,13 +26,11 @@ class Collection implements \Countable, \IteratorAggregate, \ArrayAccess
}
// https://www.php.net/manual/en/class.iteratoraggregate.php
public function getIterator()
public function getIterator(): \Generator
{
return (function () {
while (list($key, $val) = each($this->items)) {
yield $key => $val;
}
})();
foreach ($this->items as $key => $val) {
yield $key => $val;
}
}
// https://www.php.net/manual/en/class.arrayaccess.php
@@ -120,7 +118,7 @@ class Collection implements \Countable, \IteratorAggregate, \ArrayAccess
}
}
return $this->items;
return $this;
}
function first()