- Some small bugfixes done

This commit is contained in:
mcndave committed 2023-03-23 14:56:13 +00:00
1 parent fa8adcace1
commit 58bdce0ea8
5 files changed
+28 -9

No files matched your search

+10 -3
View File
@@ -49,6 +49,11 @@ class EntityCollection extends \ArrayObject {
return $this->filtersCollection($callback, true, false)->toArray();
}
public function filtersCount(Callable $callback) : array
{
return $this->filtersCollection($callback, true, false)->count();
}
public function filtersOne(Callable $callback) : ? object
{
foreach($this->filters($callback, true) as $item) {
@@ -209,7 +214,7 @@ class EntityCollection extends \ArrayObject {
return $list;
}
public function unique(/*stringable|callable */ $field, bool $strict = false) : self
public function unique(\Stringable|callable $field, bool $strict = false) : self
{
$list = [];
$obj = new static();
@@ -390,14 +395,16 @@ class EntityCollection extends \ArrayObject {
return $this;
}
public function sort(callable $callback, $function = "uasort") : self
public function sort(null|callable $callback = null, $function = "uasort") : self
{
$callback ??= fn($e1, $e2) => $e1 <=> $e2;
call_user_func_array([ $this, $function ], [ $callback ]);
return $this;
}
public function rsort(callable $callback, $function = "uasort") : self
public function rsort(null|callable $callback = null, $function = "uasort") : self
{
return $this->sort(...func_get_args())->reverse();
}