import { ValueObject } from '../../../core/domain' ; import { RecurringBillPeriodNotValidError } from '../exception/recurring-bill-period-not-valid.error' ; export enum PeriodTypes { Daily = 1 , Weekly = 7 , Monthly = 30 , Anually = 365 } interface Props { value : PeriodTypes ; } export class RecurringBillPeriod extends ValueObject < Props > { public static fromNumber ( type ) { if ( type in PeriodTypes === false ) { throw RecurringBillPeriodNotValidError . withType ( type ) ; } return new RecurringBillPeriod ( { value : type } ) ; } public static daily ( ) { return new RecurringBillPeriod ( { value : PeriodTypes . Daily } ) ; } public static weekly ( ) { return new RecurringBillPeriod ( { value : PeriodTypes . Weekly } ) ; } public static monthly ( ) { return new RecurringBillPeriod ( { value : PeriodTypes . Monthly } ) ; } public static anually ( ) { return new RecurringBillPeriod ( { value : PeriodTypes . Anually } ) ; } get value ( ) : PeriodTypes { return this . props . value ; } }