some progress on card balance
This commit is contained in:
@@ -45,3 +45,63 @@ function emptyModule(): ModuleContract
|
||||
{
|
||||
return modular()->emptyModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an anonymous class that acts as a dynamic object.
|
||||
*
|
||||
* @param mixed ...$arguments Key-value pairs passed as an associative array.
|
||||
* @return object Anonymous class instance with dynamic properties.
|
||||
*/
|
||||
function emptyClass(...$arguments): object
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed> $arguments
|
||||
*/
|
||||
return new class($arguments)
|
||||
{
|
||||
/**
|
||||
* Internal data storage.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
private array $data = [];
|
||||
|
||||
/**
|
||||
* Constructor that sets properties.
|
||||
*
|
||||
* @param array<string, mixed> $props
|
||||
*/
|
||||
public function __construct(array $props)
|
||||
{
|
||||
foreach ($props as $key => $value) {
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter.
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function __get(string $key): mixed
|
||||
{
|
||||
return $this->data[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic setter.
|
||||
*/
|
||||
public function __set(string $key, mixed $value): void
|
||||
{
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic isset.
|
||||
*/
|
||||
public function __isset(string $key): bool
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user