wpdatatables
/
lib
/
phpoffice
/
phpspreadsheet
/
src
/
PhpSpreadsheet
/
Calculation
/
Statistical
/
StatisticalValidations.php
StatisticalValidations.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/StatisticalValidations.php
| 1 | <?php |
| 2 | |
| 3 | namespace PhpOffice\PhpSpreadsheet\Calculation\Statistical; |
| 4 | |
| 5 | use PhpOffice\PhpSpreadsheet\Calculation\Exception; |
| 6 | use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; |
| 7 | |
| 8 | class StatisticalValidations |
| 9 | { |
| 10 | /** |
| 11 | * @param mixed $value |
| 12 | */ |
| 13 | public static function validateFloat($value): float |
| 14 | { |
| 15 | if (!is_numeric($value)) { |
| 16 | throw new Exception(ExcelError::VALUE()); |
| 17 | } |
| 18 | |
| 19 | return (float) $value; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * @param mixed $value |
| 24 | */ |
| 25 | public static function validateInt($value): int |
| 26 | { |
| 27 | if (!is_numeric($value)) { |
| 28 | throw new Exception(ExcelError::VALUE()); |
| 29 | } |
| 30 | |
| 31 | return (int) floor((float) $value); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @param mixed $value |
| 36 | */ |
| 37 | public static function validateBool($value): bool |
| 38 | { |
| 39 | if (!is_bool($value) && !is_numeric($value)) { |
| 40 | throw new Exception(ExcelError::VALUE()); |
| 41 | } |
| 42 | |
| 43 | return (bool) $value; |
| 44 | } |
| 45 | } |
| 46 |