Passed
Pull Request — master (#248)
by
unknown
01:38
created

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

Complexity

Total Complexity 3
Complexity/F 3

Size

Lines of Code 33
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

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(
10
        leaves: LeaveRequest[]
11
    ) {
12
        this.distributeLeavesByType(leaves);
13
    }
14
15
    private distributeLeavesByType(leaves: LeaveRequest[]): void {
16
        for (const leave of leaves) {
17
            switch (leave.getType()) {
18
                case Type.PAID:
19
                    this.paid.push(leave);
20
                    break;
21
                case Type.UNPAID:
22
                    this.unpaid.push(leave);
23
                    break;
24
                case Type.SPECIAL:
25
                    this.special.push(leave);
26
                    break;
27
                case Type.MEDICAL:
28
                    this.medical.push(leave);
29
            }
30
        }
31
    }
32
}
33