Passed
Push — develop ( a05353...e2fd1b )
by Endre
04:09
created

src/Theme/ThemesRegistry.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 30
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 30
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
wmc 2
mnd 0
bc 0
fnc 2
bpm 0
cpm 1
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A ThemesRegistry.getTheme 0 7 1
A ThemesRegistry.registerTheme 0 3 1
1
export interface Theme {
2
  name: string,
3
  isBuildIn: boolean,
4
  url: string
5
}
6
7
interface ThemesDictionary {
8
  [name: string]: Theme
9
}
10
11
export default class ThemesRegistry {
12
  protected registeredThemes: ThemesDictionary;
13
14
  constructor() {
15 5
    this.registeredThemes = {};
16
  }
17
18
  registerTheme(theme: Theme) {
19 5
    this.registeredThemes[theme.name] = theme;
20
  }
21
22
  getTheme(name: string): Theme {
23 7
    return this.registeredThemes[name] ||
24
      {
25
        name: 'Unknown',
26
        isBuildIn: true,
27
        url: 'Themes/Unknown'
28
      };
29
  }
30
}