wpdatatables
/
lib
/
phpoffice
/
phpspreadsheet
/
src
/
PhpSpreadsheet
/
Calculation
/
Statistical
/
AggregateBase.php
AggregateBase.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php
| 1 | <?php |
| 2 | |
| 3 | namespace PhpOffice\PhpSpreadsheet\Calculation\Statistical; |
| 4 | |
| 5 | use PhpOffice\PhpSpreadsheet\Calculation\Functions; |
| 6 | |
| 7 | abstract class AggregateBase |
| 8 | { |
| 9 | /** |
| 10 | * MS Excel does not count Booleans if passed as cell values, but they are counted if passed as literals. |
| 11 | * OpenOffice Calc always counts Booleans. |
| 12 | * Gnumeric never counts Booleans. |
| 13 | * |
| 14 | * @param mixed $arg |
| 15 | * @param mixed $k |
| 16 | * |
| 17 | * @return int|mixed |
| 18 | */ |
| 19 | protected static function testAcceptedBoolean($arg, $k) |
| 20 | { |
| 21 | if (!is_bool($arg)) { |
| 22 | return $arg; |
| 23 | } |
| 24 | if (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_GNUMERIC) { |
| 25 | return $arg; |
| 26 | } |
| 27 | if (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE) { |
| 28 | return (int) $arg; |
| 29 | } |
| 30 | if (!Functions::isCellValue($k)) { |
| 31 | return (int) $arg; |
| 32 | } |
| 33 | /*if ( |
| 34 | (is_bool($arg)) && |
| 35 | ((!Functions::isCellValue($k) && (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_EXCEL)) || |
| 36 | (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE)) |
| 37 | ) { |
| 38 | $arg = (int) $arg; |
| 39 | }*/ |
| 40 | |
| 41 | return $arg; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @param mixed $arg |
| 46 | * @param mixed $k |
| 47 | * |
| 48 | * @return bool |
| 49 | */ |
| 50 | protected static function isAcceptedCountable($arg, $k, bool $countNull = false) |
| 51 | { |
| 52 | if ($countNull && $arg === null && !Functions::isCellValue($k) && Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC) { |
| 53 | return true; |
| 54 | } |
| 55 | if (!is_numeric($arg)) { |
| 56 | return false; |
| 57 | } |
| 58 | if (!is_string($arg)) { |
| 59 | return true; |
| 60 | } |
| 61 | if (!Functions::isCellValue($k) && Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE) { |
| 62 | return true; |
| 63 | } |
| 64 | if (!Functions::isCellValue($k) && Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC) { |
| 65 | return true; |
| 66 | } |
| 67 | |
| 68 | return false; |
| 69 | } |
| 70 | } |
| 71 |