Test Failed
Push — develop ( 8faf31...588e30 )
by Endre
06:34
created

StyleUrlFormatter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A format 0 13 3
1
import {IObserver} from '../../../Observer/Observer';
2
import {IPageData} from '../../../Router/Router';
3
4
export interface IStyleUrlFormatter {
5
  format(url: string): string;
6
}
7
8
export default class StyleUrlFormatter {
9
  protected currentPage: IObserver<IPageData>;
10
11
  constructor(currentPage: IObserver<IPageData>) {
12
    this.currentPage = currentPage;
13
  }
14
15
  format(url: string): string {
16
    const currentPage: IPageData = this.currentPage.value;
17
    let pathOffset = './';
18
    if(currentPage.depth > 0) {
19
      let index:number;
20
      pathOffset = '';
21
      for(index = 0; index < currentPage.depth; index++) {
22
        pathOffset += '../';
23
      }
24
    }
25
26
    return pathOffset + 'Style/' + url + '.css';
27
  }
28
}
29