Passed
Pull Request — master (#99)
by Mathieu
01:23
created

server/src/Domain/PayStub/Specification/IsPayStubAlreadyExist.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 19
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 14
mnd 0
bc 0
fnc 1
dl 0
loc 19
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A IsPayStubAlreadyExist.isSatisfiedBy 0 5 1
1
import {Inject} from '@nestjs/common';
2
import {User} from 'src/Domain/User/User.entity';
3
import {IPayStubRepository} from '../Repository/IPayStubRepository';
4
import {PayStub} from '../PayStub.entity';
5
6
export class IsPayStubAlreadyExist {
7
  constructor(
8
    @Inject('IPayStubRepository')
9
    private readonly payStubRepository: IPayStubRepository
10
  ) {}
11
12
  public async isSatisfiedBy(user: User, date: Date): Promise<boolean> {
13
    return (
14
      (await this.payStubRepository.findOneByUserAndDate(user, date)) instanceof
15
      PayStub
16
    );
17
  }
18
}
19