| Total Complexity | 13 |
| Total Lines | 92 |
| Duplicated Lines | 0 % |
| Coverage | 90.48% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class BHDValidator implements ValidatorInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * {@inheritdoc} |
||
| 11 | */ |
||
| 12 | 2 | public static function validate(array $deposit) |
|
| 13 | { |
||
| 14 | 2 | if (!self::dateIsSet($deposit[0]) || !self::referenceIsSet($deposit[4]) || !self::amountIsSet($deposit[6])) { |
|
| 15 | return false; |
||
| 16 | } |
||
| 17 | |||
| 18 | 2 | if (self::amountIsZero($deposit[6])) { |
|
| 19 | 2 | return false; |
|
| 20 | } |
||
| 21 | |||
| 22 | 2 | if (self::isWithdraw($deposit[4]) || self::isAnnulment($deposit[4])) { |
|
| 23 | return false; |
||
| 24 | } |
||
| 25 | |||
| 26 | 2 | return true; |
|
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Checks if the amount is equal to zero. |
||
| 31 | * |
||
| 32 | * @param int $amount |
||
| 33 | * |
||
| 34 | * @return bool |
||
| 35 | */ |
||
| 36 | 2 | private static function amountIsZero($amount) |
|
| 37 | { |
||
| 38 | 2 | return $amount == 0; |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Checks if date is set. |
||
| 43 | * |
||
| 44 | * @param string $date |
||
| 45 | * |
||
| 46 | * @return bool |
||
| 47 | */ |
||
| 48 | 2 | private static function dateIsSet($date) |
|
| 49 | { |
||
| 50 | 2 | return isset($date); |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Checks if reference is set. |
||
| 55 | * |
||
| 56 | * @param string $reference |
||
| 57 | * |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | 2 | private static function referenceIsSet($reference) |
|
| 61 | { |
||
| 62 | 2 | return isset($reference); |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Checks if amount is set. |
||
| 67 | * |
||
| 68 | * @param string $amount |
||
| 69 | * |
||
| 70 | * @return bool |
||
| 71 | */ |
||
| 72 | 2 | private static function amountIsSet($amount) |
|
| 73 | { |
||
| 74 | 2 | return isset($amount); |
|
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Checks if the deposit is a withdraw. |
||
| 79 | * |
||
| 80 | * @param string $description |
||
| 81 | * |
||
| 82 | * @return bool |
||
| 83 | */ |
||
| 84 | 2 | private static function isWithdraw($description) |
|
| 87 | 2 | } |
|
| 88 | |||
| 89 | /** |
||
| 90 | * Checks if amount is set. |
||
| 91 | * |
||
| 92 | * @param string $description |
||
| 93 | * |
||
| 94 | * @return bool |
||
| 95 | */ |
||
| 96 | 2 | private static function isAnnulment($description) |
|
| 99 | 2 | } |
|
| 100 | } |
||
| 101 |