tablepress
/
libraries
/
vendor
/
PhpSpreadsheet
/
Calculation
/
Financial
/
CashFlow
/
CashFlowValidations.php
CashFlowValidations.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php
| 1 | <?php |
| 2 | |
| 3 | namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow; |
| 4 | |
| 5 | use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Exception; |
| 6 | use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; |
| 7 | use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Financial\FinancialValidations; |
| 8 | use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; |
| 9 | |
| 10 | class CashFlowValidations extends FinancialValidations |
| 11 | { |
| 12 | /** |
| 13 | * @param mixed $rate |
| 14 | */ |
| 15 | public static function validateRate($rate): float |
| 16 | { |
| 17 | $rate = self::validateFloat($rate); |
| 18 | |
| 19 | return $rate; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * @param mixed $type |
| 24 | */ |
| 25 | public static function validatePeriodType($type): int |
| 26 | { |
| 27 | $rate = self::validateInt($type); |
| 28 | if ( |
| 29 | $type !== FinancialConstants::PAYMENT_END_OF_PERIOD |
| 30 | && $type !== FinancialConstants::PAYMENT_BEGINNING_OF_PERIOD |
| 31 | ) { |
| 32 | throw new Exception(ExcelError::NAN()); |
| 33 | } |
| 34 | |
| 35 | return $rate; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @param mixed $presentValue |
| 40 | */ |
| 41 | public static function validatePresentValue($presentValue): float |
| 42 | { |
| 43 | return self::validateFloat($presentValue); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @param mixed $futureValue |
| 48 | */ |
| 49 | public static function validateFutureValue($futureValue): float |
| 50 | { |
| 51 | return self::validateFloat($futureValue); |
| 52 | } |
| 53 | } |
| 54 |