-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoan.php
More file actions
111 lines (94 loc) · 2.51 KB
/
Loan.php
File metadata and controls
111 lines (94 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
declare(strict_types=1);
namespace Increase\AccountStatements\AccountStatement;
use Increase\Core\Attributes\Required;
use Increase\Core\Concerns\SdkModel;
use Increase\Core\Contracts\BaseModel;
/**
* The loan balances.
*
* @phpstan-type LoanShape = array{
* dueAt: \DateTimeInterface|null, dueBalance: int, pastDueBalance: int
* }
*/
final class Loan implements BaseModel
{
/** @use SdkModel<LoanShape> */
use SdkModel;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment is due.
*/
#[Required('due_at')]
public ?\DateTimeInterface $dueAt;
/**
* The total amount due on the loan.
*/
#[Required('due_balance')]
public int $dueBalance;
/**
* The amount past due on the loan.
*/
#[Required('past_due_balance')]
public int $pastDueBalance;
/**
* `new Loan()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* Loan::with(dueAt: ..., dueBalance: ..., pastDueBalance: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new Loan)->withDueAt(...)->withDueBalance(...)->withPastDueBalance(...)
* ```
*/
public function __construct()
{
$this->initialize();
}
/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*/
public static function with(
?\DateTimeInterface $dueAt,
int $dueBalance,
int $pastDueBalance
): self {
$self = new self;
$self['dueAt'] = $dueAt;
$self['dueBalance'] = $dueBalance;
$self['pastDueBalance'] = $pastDueBalance;
return $self;
}
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment is due.
*/
public function withDueAt(?\DateTimeInterface $dueAt): self
{
$self = clone $this;
$self['dueAt'] = $dueAt;
return $self;
}
/**
* The total amount due on the loan.
*/
public function withDueBalance(int $dueBalance): self
{
$self = clone $this;
$self['dueBalance'] = $dueBalance;
return $self;
}
/**
* The amount past due on the loan.
*/
public function withPastDueBalance(int $pastDueBalance): self
{
$self = clone $this;
$self['pastDueBalance'] = $pastDueBalance;
return $self;
}
}