PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Calculation / MathTrig / Logarithms.php

Logarithms.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Calculation/MathTrig/Logarithms.php

103 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
6 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Exception;
7
8 class Logarithms
9 {
10 use ArrayEnabled;
11
12 /**
13 * LOG_BASE.
14 *
15 * Returns the logarithm of a number to a specified base. The default base is 10.
16 *
17 * Excel Function:
18 * LOG(number[,base])
19 *
20 * @param mixed $number The positive real number for which you want the logarithm
21 * Or can be an array of values
22 * @param mixed $base The base of the logarithm. If base is omitted, it is assumed to be 10.
23 * Or can be an array of values
24 *
25 * @return array<mixed>|float|string The result, or a string containing an error
26 * If an array of numbers is passed as an argument, then the returned result will also be an array
27 * with the same dimensions
28 */
29 public static function withBase($number, $base = 10)
30 {
31 if (is_array($number) || is_array($base)) {
32 return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $base);
33 }
34
35 try {
36 $number = Helpers::validateNumericNullBool($number);
37 Helpers::validatePositive($number);
38 $base = Helpers::validateNumericNullBool($base);
39 Helpers::validatePositive($base);
40 } catch (Exception $e) {
41 return $e->getMessage();
42 }
43
44 return log($number, $base);
45 }
46
47 /**
48 * LOG10.
49 *
50 * Returns the result of builtin function log after validating args.
51 *
52 * @param mixed $number Should be numeric
53 * Or can be an array of values
54 *
55 * @return array<mixed>|float|string Rounded number
56 * If an array of numbers is passed as an argument, then the returned result will also be an array
57 * with the same dimensions
58 */
59 public static function base10($number)
60 {
61 if (is_array($number)) {
62 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number);
63 }
64
65 try {
66 $number = Helpers::validateNumericNullBool($number);
67 Helpers::validatePositive($number);
68 } catch (Exception $e) {
69 return $e->getMessage();
70 }
71
72 return log10($number);
73 }
74
75 /**
76 * LN.
77 *
78 * Returns the result of builtin function log after validating args.
79 *
80 * @param mixed $number Should be numeric
81 * Or can be an array of values
82 *
83 * @return array<mixed>|float|string Rounded number
84 * If an array of numbers is passed as an argument, then the returned result will also be an array
85 * with the same dimensions
86 */
87 public static function natural($number)
88 {
89 if (is_array($number)) {
90 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number);
91 }
92
93 try {
94 $number = Helpers::validateNumericNullBool($number);
95 Helpers::validatePositive($number);
96 } catch (Exception $e) {
97 return $e->getMessage();
98 }
99
100 return log($number);
101 }
102 }
103