Differences Between: [Versions 400 and 403] [Versions 401 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\Engineering; 4 5 use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; 6 use PhpOffice\PhpSpreadsheet\Calculation\Exception; 7 use PhpOffice\PhpSpreadsheet\Calculation\Functions; 8 use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; 9 10 abstract class ConvertBase 11 { 12 use ArrayEnabled; 13 14 /** @param mixed $value */ 15 protected static function validateValue($value): string 16 { 17 if (is_bool($value)) { 18 if (Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_OPENOFFICE) { 19 throw new Exception(ExcelError::VALUE()); 20 } 21 $value = (int) $value; 22 } 23 24 if (is_numeric($value)) { 25 if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { 26 $value = floor((float) $value); 27 } 28 } 29 30 return strtoupper((string) $value); 31 } 32 33 /** @param mixed $places */ 34 protected static function validatePlaces($places = null): ?int 35 { 36 if ($places === null) { 37 return $places; 38 } 39 40 if (is_numeric($places)) { 41 if ($places < 0 || $places > 10) { 42 throw new Exception(ExcelError::NAN()); 43 } 44 45 return (int) $places; 46 } 47 48 throw new Exception(ExcelError::VALUE()); 49 } 50 51 /** 52 * Formats a number base string value with leading zeroes. 53 * 54 * @param string $value The "number" to pad 55 * @param ?int $places The length that we want to pad this value 56 * 57 * @return string The padded "number" 58 */ 59 protected static function nbrConversionFormat(string $value, ?int $places): string 60 { 61 if ($places !== null) { 62 if (strlen($value) <= $places) { 63 return substr(str_pad($value, $places, '0', STR_PAD_LEFT), -10); 64 } 65 66 return ExcelError::NAN(); 67 } 68 69 return substr($value, -10); 70 } 71 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body