Completed
Push — master ( e5af60...2118df )
by Mathieu
23s queued 13s
created

server/src/Domain/HumanResource/Leave/UserLeavesCollection.ts   A

Complexity

Total Complexity 3
Complexity/F 3

Size

Lines of Code 31
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 24
mnd 2
bc 2
fnc 1
dl 0
loc 31
rs 10
bpm 2
cpm 3
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A UserLeavesCollection.distributeLeavesByType 0 15 3
1
import { LeaveRequest, Type } from './LeaveRequest.entity';
2
3
export class UserLeavesCollection {
4
  public paid: LeaveRequest[] = [];
5
  public unpaid: LeaveRequest[] = [];
6
  public special: LeaveRequest[] = [];
7
  public medical: LeaveRequest[] = [];
8
9
  constructor(leaves: LeaveRequest[]) {
10
    this.distributeLeavesByType(leaves);
11
  }
12
13
  private distributeLeavesByType(leaves: LeaveRequest[]): void {
14
    for (const leave of leaves) {
15
      switch (leave.getType()) {
16
        case Type.PAID:
17
          this.paid.push(leave);
18
          break;
19
        case Type.UNPAID:
20
          this.unpaid.push(leave);
21
          break;
22
        case Type.SPECIAL:
23
          this.special.push(leave);
24
          break;
25
        case Type.MEDICAL:
26
          this.medical.push(leave);
27
      }
28
    }
29
  }
30
}
31