src/js/core/Config.js   A
last analyzed

Size

Lines of Code 27

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
nc 1
dl 0
loc 27
ccs 3
cts 3
cp 1
rs 10
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A Config.js ➔ ??? 0 3 1
1
/**
2
 * Class to handle configurations of the application
3
 *
4
 * @class Config
5
 */
6
class Config {
7
    constructor() {
8 1
        this._configs = [];
9
    }
10
11
    /**
12
     * Set a new or update an existing configuration
13
     * @param {String} configName Config name
14
     * @param {*} value Config value
15
     */
16
    set(configName, value) {
17 1
        this._configs[configName] = value;
18
    }
19
20
    /**
21
     * Get the value of the configuration or the default value
22
     *
23
     * @param {String} configName Config name
24
     * @param {*} defaultValue Value to return if config doesn't exists
25
     * @returns {*}
26
     */
27
    get(configName, defaultValue = null) {
28 4
        return this._configs[configName] || defaultValue;
29
    }
30
}
31
32
export default Config;
33