Total Complexity | 7 |
Total Lines | 77 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | class PersonalStatementRequest |
||
15 | { |
||
16 | private const MAX_PERIOD_IN_SECONDS = 2678400; |
||
17 | |||
18 | /** |
||
19 | * @var DateTimeInterface |
||
20 | */ |
||
21 | private $from; |
||
22 | |||
23 | /** |
||
24 | * @var DateTimeInterface |
||
25 | */ |
||
26 | private $to; |
||
27 | |||
28 | /** |
||
29 | * @var AccountID |
||
30 | */ |
||
31 | private $accountID; |
||
32 | |||
33 | /** |
||
34 | * The maximum time for which it is possible to extract is 31 days (2678400 seconds). |
||
35 | * |
||
36 | * @param DateTimeInterface $from |
||
37 | * @param DateTimeInterface $to |
||
38 | * |
||
39 | * @throws RequestException |
||
40 | */ |
||
41 | public function __construct(DateTimeInterface $from, DateTimeInterface $to) |
||
42 | { |
||
43 | if ($from > $to) { |
||
44 | throw RequestException::invalidPersonalStatementPeriod(); |
||
45 | } |
||
46 | |||
47 | $diffInSeconds = $to->getTimestamp() - $from->getTimestamp(); |
||
48 | |||
49 | if ($diffInSeconds > self::MAX_PERIOD_IN_SECONDS) { |
||
50 | throw RequestException::maxPersonalStatementPeriod(); |
||
51 | } |
||
52 | |||
53 | $this->from = $from; |
||
54 | $this->to = $to; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @return DateTimeInterface |
||
59 | */ |
||
60 | public function getFrom(): DateTimeInterface |
||
61 | { |
||
62 | return $this->from; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return DateTimeInterface |
||
67 | */ |
||
68 | public function getTo(): DateTimeInterface |
||
69 | { |
||
70 | return $this->to; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @return AccountID|null |
||
75 | */ |
||
76 | public function getAccountID(): ?AccountID |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param AccountID $accountID |
||
83 | * |
||
84 | * @return PersonalStatementRequest |
||
85 | */ |
||
86 | public function setAccountID(AccountID $accountID): self |
||
91 | } |
||
92 | } |
||
93 |