table = $table; } public function where($key, $value) { $this->where[$key] = $value; return $this; } public function get() { return array_values(array_filter($GLOBALS['db'][$this->table] ?? [], function ($row) { foreach ($this->where as $key => $value) if ($row->$key != $value) return false; return true; })); } public function first() { return $this->get()[0] ?? null; } } } namespace { class BackupTestClient extends \WHMCS\User\Client { public $id; public $permitted; public function __construct($id, $permitted = true) { $this->id = $id; $this->permitted = $permitted; } public function hasPermission($permission) { throw new \RuntimeException('Unsupported client permission API'); } } class BackupTestUser { public function getClientsByPermission($permission) { if (isset($GLOBALS['permissionClients'])) return $GLOBALS['permissionClients']; $c=$GLOBALS['actor']??null; return $permission==='products' && $c && $c->permitted ? [$c] : []; } } function logActivity($message) { $GLOBALS['safeLogs'][] = $message; } }