update 2024-05-16 16:19:46

This commit is contained in:
Robot 2024-05-16 16:19:49 +02:00
parent 84ef5ae035
commit d3573db90e
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
3 changed files with 37 additions and 2 deletions

View File

@ -13,6 +13,7 @@
abstract ActiveRegistry #Orange {
# array $active
# bool $addAsArray
# bool $uniqueArray
+ isActive() : bool
+ allActive() : array
+ setActive(mixed $value, $keys) : void

View File

@ -40,6 +40,14 @@ abstract class ActiveRegistry implements Activeregistryinterface
**/
protected bool $addAsArray = false;
/**
* Base switch to keep array values unique
*
* @var boolean
* @since 3.2.2
**/
protected bool $uniqueArray = false;
/**
* Check if the registry has any content.
*
@ -157,7 +165,16 @@ abstract class ActiveRegistry implements Activeregistryinterface
// Convert to array if it's not already an array
$array = [$array];
}
$array[] = $value;
if ($this->uniqueArray && in_array($value, $array))
{
// we do nothing
return;
}
else
{
$array[] = $value;
}
}
else
{

View File

@ -14,6 +14,14 @@
**/
protected bool $addAsArray = false;
/**
* Base switch to keep array values unique
*
* @var boolean
* @since 3.2.2
**/
protected bool $uniqueArray = false;
/**
* Check if the registry has any content.
*
@ -131,7 +139,16 @@
// Convert to array if it's not already an array
$array = [$array];
}
$array[] = $value;
if ($this->uniqueArray && in_array($value, $array))
{
// we do nothing
return;
}
else
{
$array[] = $value;
}
}
else
{