jsOMS/Account/AccountManager.js
Dennis Eichhorn 7b75ec58f7
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
CI / general_module_workflow_js (push) Has been cancelled
fix permissions
2025-04-02 14:15:07 +00:00

78 lines
1.2 KiB
JavaScript

/**
* @typedef {import('./Account.js').Account} Account
*/
/**
* Account Manager.
*
* @copyright Dennis Eichhorn
* @license OMS License 2.2
* @version 1.0.0
* @since 1.0.0
*/
export class AccountManager
{
/**
* @constructor
*
* @since 1.0.0
*/
constructor ()
{
/** @type {Account[]} accounts Accounts */
this.accounts = [];
};
/**
* Add account.
*
* @param {Account} account Account
*
* @return {void}
*
* @since 1.0.0
*/
add (account)
{
this.accounts[account.getId()] = account;
};
/**
* Remove account.
*
* @param {number} id Account id
*
* @return {boolean}
*
* @since 1.0.0
*/
remove (id)
{
if (typeof this.accounts[id] !== 'undefined') {
delete this.accounts[id];
return true;
}
return false;
};
/**
* Get account by id.
*
* @param {number} id Account id
*
* @return {null|Account}
*
* @since 1.0.0
*/
get (id)
{
if (this.accounts[id]) {
return this.accounts[id];
}
return null;
};
};