1 | <?php |
||
18 | class BankAccountValidator |
||
19 | { |
||
20 | private $bank_account; |
||
21 | |||
22 | /** |
||
23 | * BankAccountValidator constructor. |
||
24 | * @param BankAccount $bankAccount |
||
25 | */ |
||
26 | public function __construct(BankAccount $bankAccount) |
||
30 | |||
31 | /** |
||
32 | * This validate the bank account |
||
33 | */ |
||
34 | public function validate(): void |
||
42 | |||
43 | /** |
||
44 | * This validate a bank branch |
||
45 | */ |
||
46 | private function validateBranch() |
||
47 | { |
||
48 | $branch = $this->bank_account->branch; |
||
49 | if (is_null($branch) || !is_string($branch) || !is_numeric($branch)) { |
||
50 | throw new \InvalidArgumentException('branch should be a numeric string'); |
||
51 | } |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * This validate a bank account |
||
56 | */ |
||
57 | private function validateAccount() |
||
58 | { |
||
59 | $account = $this->bank_account->account; |
||
60 | if (is_null($account) || !is_string($account) || !is_numeric($account)) { |
||
61 | throw new \InvalidArgumentException('account should be a numeric string'); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * This validates a cpf_cnpj |
||
67 | */ |
||
68 | private function validateDocument() |
||
77 | |||
78 | /** |
||
79 | * This validates a given name |
||
80 | */ |
||
81 | private function validateName() |
||
82 | { |
||
83 | $name = $this->bank_account->name; |
||
84 | if (is_null($name) || !is_string($name)) { |
||
85 | throw new \InvalidArgumentException('name should be a string'); |
||
86 | } |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * This validates bank account type |
||
91 | */ |
||
92 | private function validateAccountType() |
||
100 | } |
||
101 |