- Work done on Ulmus which were added within the Bottin de suppléance app
This commit is contained in:
1 parent
7fb591e1f5
commit
9ad2e94d12
9 files changed
+219
-127
No files matched your search
@@ -87,6 +87,13 @@ class EntityCollection extends \ArrayObject {
|
||||
return $removed;
|
||||
}
|
||||
|
||||
public function clear() : self
|
||||
{
|
||||
$this->exchangeArray([]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function search($value, string $field, bool $strict = true) : Generator
|
||||
{
|
||||
foreach($this->filters(fn($v) => isset($v->$field) ? ( $strict ? $v->$field === $value : $v->$field == $value ) : false) as $key => $item) {
|
||||
@@ -134,6 +141,11 @@ class EntityCollection extends \ArrayObject {
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function searchInstances(string $className) : self
|
||||
{
|
||||
return $this->filtersCollection(fn($obj) => is_a($obj, $className));
|
||||
}
|
||||
|
||||
public function column($field, bool $unique = false) : array
|
||||
{
|
||||
$list = [];
|
||||
@@ -146,8 +158,8 @@ class EntityCollection extends \ArrayObject {
|
||||
$value = $item->$field;
|
||||
}
|
||||
|
||||
if ($unique && in_array($value, $list)) {
|
||||
break;
|
||||
if ($unique && in_array($value, $list, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$list[] = $value;
|
||||
@@ -279,6 +291,13 @@ class EntityCollection extends \ArrayObject {
|
||||
}
|
||||
}
|
||||
|
||||
public function push($value) : self
|
||||
{
|
||||
$this->append($value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function mergeWith( /*array|EntityCollection*/ $datasets ) : self
|
||||
{
|
||||
if ( is_object($datasets) ) {
|
||||
@@ -331,6 +350,11 @@ class EntityCollection extends \ArrayObject {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function rsort(callable $callback, $function = "uasort") : self
|
||||
{
|
||||
return $this->sort(...func_get_args())->reverse();
|
||||
}
|
||||
|
||||
public function pop() /* : mixed */
|
||||
{
|
||||
$arr = $this->getArrayCopy();
|
||||
|
||||
Reference in new issue
Block a user