@@ -757,6 +757,9 @@ discard block |
||
757 | 757 | } |
758 | 758 | |
759 | 759 | |
760 | + /** |
|
761 | + * @param string $xVal |
|
762 | + */ |
|
760 | 763 | private static function _nbrConversionFormat($xVal,$places) { |
761 | 764 | if (!is_null($places)) { |
762 | 765 | if (strlen($xVal) <= $places) { |
@@ -1716,7 +1719,7 @@ discard block |
||
1716 | 1719 | * @access public |
1717 | 1720 | * @category Engineering Functions |
1718 | 1721 | * @param string $complexNumber The complex number for which you want the real coefficient. |
1719 | - * @return float |
|
1722 | + * @return string |
|
1720 | 1723 | */ |
1721 | 1724 | public static function IMREAL($complexNumber) { |
1722 | 1725 | $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); |
@@ -2121,7 +2124,6 @@ discard block |
||
2121 | 2124 | * Excel Function: |
2122 | 2125 | * IMSUM(complexNumber[,complexNumber[,...]]) |
2123 | 2126 | * |
2124 | - * @param string $complexNumber,... Series of complex numbers to add |
|
2125 | 2127 | * @return string |
2126 | 2128 | */ |
2127 | 2129 | public static function IMSUM() { |
@@ -2157,7 +2159,6 @@ discard block |
||
2157 | 2159 | * Excel Function: |
2158 | 2160 | * IMPRODUCT(complexNumber[,complexNumber[,...]]) |
2159 | 2161 | * |
2160 | - * @param string $complexNumber,... Series of complex numbers to multiply |
|
2161 | 2162 | * @return string |
2162 | 2163 | */ |
2163 | 2164 | public static function IMPRODUCT() { |
@@ -2197,7 +2198,7 @@ discard block |
||
2197 | 2198 | * DELTA(a[,b]) |
2198 | 2199 | * |
2199 | 2200 | * @param float $a The first number. |
2200 | - * @param float $b The second number. If omitted, b is assumed to be zero. |
|
2201 | + * @param integer $b The second number. If omitted, b is assumed to be zero. |
|
2201 | 2202 | * @return int |
2202 | 2203 | */ |
2203 | 2204 | public static function DELTA($a, $b=0) { |
@@ -2219,7 +2220,7 @@ discard block |
||
2219 | 2220 | * functions you calculate the count of values that exceed a threshold. |
2220 | 2221 | * |
2221 | 2222 | * @param float $number The value to test against step. |
2222 | - * @param float $step The threshold value. |
|
2223 | + * @param integer $step The threshold value. |
|
2223 | 2224 | * If you omit a value for step, GESTEP uses zero. |
2224 | 2225 | * @return int |
2225 | 2226 | */ |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -54,69 +54,69 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @var mixed[] |
56 | 56 | */ |
57 | - private static $_conversionUnits = array( 'g' => array( 'Group' => 'Mass', 'Unit Name' => 'Gram', 'AllowPrefix' => True ), |
|
58 | - 'sg' => array( 'Group' => 'Mass', 'Unit Name' => 'Slug', 'AllowPrefix' => False ), |
|
59 | - 'lbm' => array( 'Group' => 'Mass', 'Unit Name' => 'Pound mass (avoirdupois)', 'AllowPrefix' => False ), |
|
60 | - 'u' => array( 'Group' => 'Mass', 'Unit Name' => 'U (atomic mass unit)', 'AllowPrefix' => True ), |
|
61 | - 'ozm' => array( 'Group' => 'Mass', 'Unit Name' => 'Ounce mass (avoirdupois)', 'AllowPrefix' => False ), |
|
62 | - 'm' => array( 'Group' => 'Distance', 'Unit Name' => 'Meter', 'AllowPrefix' => True ), |
|
63 | - 'mi' => array( 'Group' => 'Distance', 'Unit Name' => 'Statute mile', 'AllowPrefix' => False ), |
|
64 | - 'Nmi' => array( 'Group' => 'Distance', 'Unit Name' => 'Nautical mile', 'AllowPrefix' => False ), |
|
65 | - 'in' => array( 'Group' => 'Distance', 'Unit Name' => 'Inch', 'AllowPrefix' => False ), |
|
66 | - 'ft' => array( 'Group' => 'Distance', 'Unit Name' => 'Foot', 'AllowPrefix' => False ), |
|
67 | - 'yd' => array( 'Group' => 'Distance', 'Unit Name' => 'Yard', 'AllowPrefix' => False ), |
|
68 | - 'ang' => array( 'Group' => 'Distance', 'Unit Name' => 'Angstrom', 'AllowPrefix' => True ), |
|
69 | - 'Pica' => array( 'Group' => 'Distance', 'Unit Name' => 'Pica (1/72 in)', 'AllowPrefix' => False ), |
|
70 | - 'yr' => array( 'Group' => 'Time', 'Unit Name' => 'Year', 'AllowPrefix' => False ), |
|
71 | - 'day' => array( 'Group' => 'Time', 'Unit Name' => 'Day', 'AllowPrefix' => False ), |
|
72 | - 'hr' => array( 'Group' => 'Time', 'Unit Name' => 'Hour', 'AllowPrefix' => False ), |
|
73 | - 'mn' => array( 'Group' => 'Time', 'Unit Name' => 'Minute', 'AllowPrefix' => False ), |
|
74 | - 'sec' => array( 'Group' => 'Time', 'Unit Name' => 'Second', 'AllowPrefix' => True ), |
|
75 | - 'Pa' => array( 'Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True ), |
|
76 | - 'p' => array( 'Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True ), |
|
77 | - 'atm' => array( 'Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True ), |
|
78 | - 'at' => array( 'Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True ), |
|
79 | - 'mmHg' => array( 'Group' => 'Pressure', 'Unit Name' => 'mm of Mercury', 'AllowPrefix' => True ), |
|
80 | - 'N' => array( 'Group' => 'Force', 'Unit Name' => 'Newton', 'AllowPrefix' => True ), |
|
81 | - 'dyn' => array( 'Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True ), |
|
82 | - 'dy' => array( 'Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True ), |
|
83 | - 'lbf' => array( 'Group' => 'Force', 'Unit Name' => 'Pound force', 'AllowPrefix' => False ), |
|
84 | - 'J' => array( 'Group' => 'Energy', 'Unit Name' => 'Joule', 'AllowPrefix' => True ), |
|
85 | - 'e' => array( 'Group' => 'Energy', 'Unit Name' => 'Erg', 'AllowPrefix' => True ), |
|
86 | - 'c' => array( 'Group' => 'Energy', 'Unit Name' => 'Thermodynamic calorie', 'AllowPrefix' => True ), |
|
87 | - 'cal' => array( 'Group' => 'Energy', 'Unit Name' => 'IT calorie', 'AllowPrefix' => True ), |
|
88 | - 'eV' => array( 'Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True ), |
|
89 | - 'ev' => array( 'Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True ), |
|
90 | - 'HPh' => array( 'Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False ), |
|
91 | - 'hh' => array( 'Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False ), |
|
92 | - 'Wh' => array( 'Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True ), |
|
93 | - 'wh' => array( 'Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True ), |
|
94 | - 'flb' => array( 'Group' => 'Energy', 'Unit Name' => 'Foot-pound', 'AllowPrefix' => False ), |
|
95 | - 'BTU' => array( 'Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False ), |
|
96 | - 'btu' => array( 'Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False ), |
|
97 | - 'HP' => array( 'Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False ), |
|
98 | - 'h' => array( 'Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False ), |
|
99 | - 'W' => array( 'Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True ), |
|
100 | - 'w' => array( 'Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True ), |
|
101 | - 'T' => array( 'Group' => 'Magnetism', 'Unit Name' => 'Tesla', 'AllowPrefix' => True ), |
|
102 | - 'ga' => array( 'Group' => 'Magnetism', 'Unit Name' => 'Gauss', 'AllowPrefix' => True ), |
|
103 | - 'C' => array( 'Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False ), |
|
104 | - 'cel' => array( 'Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False ), |
|
105 | - 'F' => array( 'Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False ), |
|
106 | - 'fah' => array( 'Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False ), |
|
107 | - 'K' => array( 'Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False ), |
|
108 | - 'kel' => array( 'Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False ), |
|
109 | - 'tsp' => array( 'Group' => 'Liquid', 'Unit Name' => 'Teaspoon', 'AllowPrefix' => False ), |
|
110 | - 'tbs' => array( 'Group' => 'Liquid', 'Unit Name' => 'Tablespoon', 'AllowPrefix' => False ), |
|
111 | - 'oz' => array( 'Group' => 'Liquid', 'Unit Name' => 'Fluid Ounce', 'AllowPrefix' => False ), |
|
112 | - 'cup' => array( 'Group' => 'Liquid', 'Unit Name' => 'Cup', 'AllowPrefix' => False ), |
|
113 | - 'pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False ), |
|
114 | - 'us_pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False ), |
|
115 | - 'uk_pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.K. Pint', 'AllowPrefix' => False ), |
|
116 | - 'qt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Quart', 'AllowPrefix' => False ), |
|
117 | - 'gal' => array( 'Group' => 'Liquid', 'Unit Name' => 'Gallon', 'AllowPrefix' => False ), |
|
118 | - 'l' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True ), |
|
119 | - 'lt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True ) |
|
57 | + private static $_conversionUnits = array('g' => array('Group' => 'Mass', 'Unit Name' => 'Gram', 'AllowPrefix' => True), |
|
58 | + 'sg' => array('Group' => 'Mass', 'Unit Name' => 'Slug', 'AllowPrefix' => False), |
|
59 | + 'lbm' => array('Group' => 'Mass', 'Unit Name' => 'Pound mass (avoirdupois)', 'AllowPrefix' => False), |
|
60 | + 'u' => array('Group' => 'Mass', 'Unit Name' => 'U (atomic mass unit)', 'AllowPrefix' => True), |
|
61 | + 'ozm' => array('Group' => 'Mass', 'Unit Name' => 'Ounce mass (avoirdupois)', 'AllowPrefix' => False), |
|
62 | + 'm' => array('Group' => 'Distance', 'Unit Name' => 'Meter', 'AllowPrefix' => True), |
|
63 | + 'mi' => array('Group' => 'Distance', 'Unit Name' => 'Statute mile', 'AllowPrefix' => False), |
|
64 | + 'Nmi' => array('Group' => 'Distance', 'Unit Name' => 'Nautical mile', 'AllowPrefix' => False), |
|
65 | + 'in' => array('Group' => 'Distance', 'Unit Name' => 'Inch', 'AllowPrefix' => False), |
|
66 | + 'ft' => array('Group' => 'Distance', 'Unit Name' => 'Foot', 'AllowPrefix' => False), |
|
67 | + 'yd' => array('Group' => 'Distance', 'Unit Name' => 'Yard', 'AllowPrefix' => False), |
|
68 | + 'ang' => array('Group' => 'Distance', 'Unit Name' => 'Angstrom', 'AllowPrefix' => True), |
|
69 | + 'Pica' => array('Group' => 'Distance', 'Unit Name' => 'Pica (1/72 in)', 'AllowPrefix' => False), |
|
70 | + 'yr' => array('Group' => 'Time', 'Unit Name' => 'Year', 'AllowPrefix' => False), |
|
71 | + 'day' => array('Group' => 'Time', 'Unit Name' => 'Day', 'AllowPrefix' => False), |
|
72 | + 'hr' => array('Group' => 'Time', 'Unit Name' => 'Hour', 'AllowPrefix' => False), |
|
73 | + 'mn' => array('Group' => 'Time', 'Unit Name' => 'Minute', 'AllowPrefix' => False), |
|
74 | + 'sec' => array('Group' => 'Time', 'Unit Name' => 'Second', 'AllowPrefix' => True), |
|
75 | + 'Pa' => array('Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True), |
|
76 | + 'p' => array('Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True), |
|
77 | + 'atm' => array('Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True), |
|
78 | + 'at' => array('Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True), |
|
79 | + 'mmHg' => array('Group' => 'Pressure', 'Unit Name' => 'mm of Mercury', 'AllowPrefix' => True), |
|
80 | + 'N' => array('Group' => 'Force', 'Unit Name' => 'Newton', 'AllowPrefix' => True), |
|
81 | + 'dyn' => array('Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True), |
|
82 | + 'dy' => array('Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True), |
|
83 | + 'lbf' => array('Group' => 'Force', 'Unit Name' => 'Pound force', 'AllowPrefix' => False), |
|
84 | + 'J' => array('Group' => 'Energy', 'Unit Name' => 'Joule', 'AllowPrefix' => True), |
|
85 | + 'e' => array('Group' => 'Energy', 'Unit Name' => 'Erg', 'AllowPrefix' => True), |
|
86 | + 'c' => array('Group' => 'Energy', 'Unit Name' => 'Thermodynamic calorie', 'AllowPrefix' => True), |
|
87 | + 'cal' => array('Group' => 'Energy', 'Unit Name' => 'IT calorie', 'AllowPrefix' => True), |
|
88 | + 'eV' => array('Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True), |
|
89 | + 'ev' => array('Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True), |
|
90 | + 'HPh' => array('Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False), |
|
91 | + 'hh' => array('Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False), |
|
92 | + 'Wh' => array('Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True), |
|
93 | + 'wh' => array('Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True), |
|
94 | + 'flb' => array('Group' => 'Energy', 'Unit Name' => 'Foot-pound', 'AllowPrefix' => False), |
|
95 | + 'BTU' => array('Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False), |
|
96 | + 'btu' => array('Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False), |
|
97 | + 'HP' => array('Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False), |
|
98 | + 'h' => array('Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False), |
|
99 | + 'W' => array('Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True), |
|
100 | + 'w' => array('Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True), |
|
101 | + 'T' => array('Group' => 'Magnetism', 'Unit Name' => 'Tesla', 'AllowPrefix' => True), |
|
102 | + 'ga' => array('Group' => 'Magnetism', 'Unit Name' => 'Gauss', 'AllowPrefix' => True), |
|
103 | + 'C' => array('Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False), |
|
104 | + 'cel' => array('Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False), |
|
105 | + 'F' => array('Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False), |
|
106 | + 'fah' => array('Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False), |
|
107 | + 'K' => array('Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False), |
|
108 | + 'kel' => array('Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False), |
|
109 | + 'tsp' => array('Group' => 'Liquid', 'Unit Name' => 'Teaspoon', 'AllowPrefix' => False), |
|
110 | + 'tbs' => array('Group' => 'Liquid', 'Unit Name' => 'Tablespoon', 'AllowPrefix' => False), |
|
111 | + 'oz' => array('Group' => 'Liquid', 'Unit Name' => 'Fluid Ounce', 'AllowPrefix' => False), |
|
112 | + 'cup' => array('Group' => 'Liquid', 'Unit Name' => 'Cup', 'AllowPrefix' => False), |
|
113 | + 'pt' => array('Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False), |
|
114 | + 'us_pt' => array('Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False), |
|
115 | + 'uk_pt' => array('Group' => 'Liquid', 'Unit Name' => 'U.K. Pint', 'AllowPrefix' => False), |
|
116 | + 'qt' => array('Group' => 'Liquid', 'Unit Name' => 'Quart', 'AllowPrefix' => False), |
|
117 | + 'gal' => array('Group' => 'Liquid', 'Unit Name' => 'Gallon', 'AllowPrefix' => False), |
|
118 | + 'l' => array('Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True), |
|
119 | + 'lt' => array('Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True) |
|
120 | 120 | ); |
121 | 121 | |
122 | 122 | /** |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @var mixed[] |
126 | 126 | */ |
127 | - private static $_conversionMultipliers = array( 'Y' => array( 'multiplier' => 1E24, 'name' => 'yotta' ), |
|
128 | - 'Z' => array( 'multiplier' => 1E21, 'name' => 'zetta' ), |
|
129 | - 'E' => array( 'multiplier' => 1E18, 'name' => 'exa' ), |
|
130 | - 'P' => array( 'multiplier' => 1E15, 'name' => 'peta' ), |
|
131 | - 'T' => array( 'multiplier' => 1E12, 'name' => 'tera' ), |
|
132 | - 'G' => array( 'multiplier' => 1E9, 'name' => 'giga' ), |
|
133 | - 'M' => array( 'multiplier' => 1E6, 'name' => 'mega' ), |
|
134 | - 'k' => array( 'multiplier' => 1E3, 'name' => 'kilo' ), |
|
135 | - 'h' => array( 'multiplier' => 1E2, 'name' => 'hecto' ), |
|
136 | - 'e' => array( 'multiplier' => 1E1, 'name' => 'deka' ), |
|
137 | - 'd' => array( 'multiplier' => 1E-1, 'name' => 'deci' ), |
|
138 | - 'c' => array( 'multiplier' => 1E-2, 'name' => 'centi' ), |
|
139 | - 'm' => array( 'multiplier' => 1E-3, 'name' => 'milli' ), |
|
140 | - 'u' => array( 'multiplier' => 1E-6, 'name' => 'micro' ), |
|
141 | - 'n' => array( 'multiplier' => 1E-9, 'name' => 'nano' ), |
|
142 | - 'p' => array( 'multiplier' => 1E-12, 'name' => 'pico' ), |
|
143 | - 'f' => array( 'multiplier' => 1E-15, 'name' => 'femto' ), |
|
144 | - 'a' => array( 'multiplier' => 1E-18, 'name' => 'atto' ), |
|
145 | - 'z' => array( 'multiplier' => 1E-21, 'name' => 'zepto' ), |
|
146 | - 'y' => array( 'multiplier' => 1E-24, 'name' => 'yocto' ) |
|
127 | + private static $_conversionMultipliers = array('Y' => array('multiplier' => 1E24, 'name' => 'yotta'), |
|
128 | + 'Z' => array('multiplier' => 1E21, 'name' => 'zetta'), |
|
129 | + 'E' => array('multiplier' => 1E18, 'name' => 'exa'), |
|
130 | + 'P' => array('multiplier' => 1E15, 'name' => 'peta'), |
|
131 | + 'T' => array('multiplier' => 1E12, 'name' => 'tera'), |
|
132 | + 'G' => array('multiplier' => 1E9, 'name' => 'giga'), |
|
133 | + 'M' => array('multiplier' => 1E6, 'name' => 'mega'), |
|
134 | + 'k' => array('multiplier' => 1E3, 'name' => 'kilo'), |
|
135 | + 'h' => array('multiplier' => 1E2, 'name' => 'hecto'), |
|
136 | + 'e' => array('multiplier' => 1E1, 'name' => 'deka'), |
|
137 | + 'd' => array('multiplier' => 1E-1, 'name' => 'deci'), |
|
138 | + 'c' => array('multiplier' => 1E-2, 'name' => 'centi'), |
|
139 | + 'm' => array('multiplier' => 1E-3, 'name' => 'milli'), |
|
140 | + 'u' => array('multiplier' => 1E-6, 'name' => 'micro'), |
|
141 | + 'n' => array('multiplier' => 1E-9, 'name' => 'nano'), |
|
142 | + 'p' => array('multiplier' => 1E-12, 'name' => 'pico'), |
|
143 | + 'f' => array('multiplier' => 1E-15, 'name' => 'femto'), |
|
144 | + 'a' => array('multiplier' => 1E-18, 'name' => 'atto'), |
|
145 | + 'z' => array('multiplier' => 1E-21, 'name' => 'zepto'), |
|
146 | + 'y' => array('multiplier' => 1E-24, 'name' => 'yocto') |
|
147 | 147 | ); |
148 | 148 | |
149 | 149 | /** |
@@ -151,38 +151,38 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @var mixed[] |
153 | 153 | */ |
154 | - private static $_unitConversions = array( 'Mass' => array( 'g' => array( 'g' => 1.0, |
|
154 | + private static $_unitConversions = array('Mass' => array('g' => array('g' => 1.0, |
|
155 | 155 | 'sg' => 6.85220500053478E-05, |
156 | 156 | 'lbm' => 2.20462291469134E-03, |
157 | 157 | 'u' => 6.02217000000000E+23, |
158 | 158 | 'ozm' => 3.52739718003627E-02 |
159 | 159 | ), |
160 | - 'sg' => array( 'g' => 1.45938424189287E+04, |
|
160 | + 'sg' => array('g' => 1.45938424189287E+04, |
|
161 | 161 | 'sg' => 1.0, |
162 | 162 | 'lbm' => 3.21739194101647E+01, |
163 | 163 | 'u' => 8.78866000000000E+27, |
164 | 164 | 'ozm' => 5.14782785944229E+02 |
165 | 165 | ), |
166 | - 'lbm' => array( 'g' => 4.5359230974881148E+02, |
|
166 | + 'lbm' => array('g' => 4.5359230974881148E+02, |
|
167 | 167 | 'sg' => 3.10810749306493E-02, |
168 | 168 | 'lbm' => 1.0, |
169 | 169 | 'u' => 2.73161000000000E+26, |
170 | 170 | 'ozm' => 1.60000023429410E+01 |
171 | 171 | ), |
172 | - 'u' => array( 'g' => 1.66053100460465E-24, |
|
172 | + 'u' => array('g' => 1.66053100460465E-24, |
|
173 | 173 | 'sg' => 1.13782988532950E-28, |
174 | 174 | 'lbm' => 3.66084470330684E-27, |
175 | 175 | 'u' => 1.0, |
176 | 176 | 'ozm' => 5.85735238300524E-26 |
177 | 177 | ), |
178 | - 'ozm' => array( 'g' => 2.83495152079732E+01, |
|
178 | + 'ozm' => array('g' => 2.83495152079732E+01, |
|
179 | 179 | 'sg' => 1.94256689870811E-03, |
180 | 180 | 'lbm' => 6.24999908478882E-02, |
181 | 181 | 'u' => 1.70725600000000E+25, |
182 | 182 | 'ozm' => 1.0 |
183 | 183 | ) |
184 | 184 | ), |
185 | - 'Distance' => array( 'm' => array( 'm' => 1.0, |
|
185 | + 'Distance' => array('m' => array('m' => 1.0, |
|
186 | 186 | 'mi' => 6.21371192237334E-04, |
187 | 187 | 'Nmi' => 5.39956803455724E-04, |
188 | 188 | 'in' => 3.93700787401575E+01, |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'ang' => 1.00000000000000E+10, |
192 | 192 | 'Pica' => 2.83464566929116E+03 |
193 | 193 | ), |
194 | - 'mi' => array( 'm' => 1.60934400000000E+03, |
|
194 | + 'mi' => array('m' => 1.60934400000000E+03, |
|
195 | 195 | 'mi' => 1.0, |
196 | 196 | 'Nmi' => 8.68976241900648E-01, |
197 | 197 | 'in' => 6.33600000000000E+04, |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | 'ang' => 1.60934400000000E+13, |
201 | 201 | 'Pica' => 4.56191999999971E+06 |
202 | 202 | ), |
203 | - 'Nmi' => array( 'm' => 1.85200000000000E+03, |
|
203 | + 'Nmi' => array('m' => 1.85200000000000E+03, |
|
204 | 204 | 'mi' => 1.15077944802354E+00, |
205 | 205 | 'Nmi' => 1.0, |
206 | 206 | 'in' => 7.29133858267717E+04, |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | 'ang' => 1.85200000000000E+13, |
210 | 210 | 'Pica' => 5.24976377952723E+06 |
211 | 211 | ), |
212 | - 'in' => array( 'm' => 2.54000000000000E-02, |
|
212 | + 'in' => array('m' => 2.54000000000000E-02, |
|
213 | 213 | 'mi' => 1.57828282828283E-05, |
214 | 214 | 'Nmi' => 1.37149028077754E-05, |
215 | 215 | 'in' => 1.0, |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | 'ang' => 2.54000000000000E+08, |
219 | 219 | 'Pica' => 7.19999999999955E+01 |
220 | 220 | ), |
221 | - 'ft' => array( 'm' => 3.04800000000000E-01, |
|
221 | + 'ft' => array('m' => 3.04800000000000E-01, |
|
222 | 222 | 'mi' => 1.89393939393939E-04, |
223 | 223 | 'Nmi' => 1.64578833693305E-04, |
224 | 224 | 'in' => 1.20000000000000E+01, |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'ang' => 3.04800000000000E+09, |
228 | 228 | 'Pica' => 8.63999999999946E+02 |
229 | 229 | ), |
230 | - 'yd' => array( 'm' => 9.14400000300000E-01, |
|
230 | + 'yd' => array('m' => 9.14400000300000E-01, |
|
231 | 231 | 'mi' => 5.68181818368230E-04, |
232 | 232 | 'Nmi' => 4.93736501241901E-04, |
233 | 233 | 'in' => 3.60000000118110E+01, |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | 'ang' => 9.14400000300000E+09, |
237 | 237 | 'Pica' => 2.59200000085023E+03 |
238 | 238 | ), |
239 | - 'ang' => array( 'm' => 1.00000000000000E-10, |
|
239 | + 'ang' => array('m' => 1.00000000000000E-10, |
|
240 | 240 | 'mi' => 6.21371192237334E-14, |
241 | 241 | 'Nmi' => 5.39956803455724E-14, |
242 | 242 | 'in' => 3.93700787401575E-09, |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'ang' => 1.0, |
246 | 246 | 'Pica' => 2.83464566929116E-07 |
247 | 247 | ), |
248 | - 'Pica' => array( 'm' => 3.52777777777800E-04, |
|
248 | + 'Pica' => array('m' => 3.52777777777800E-04, |
|
249 | 249 | 'mi' => 2.19205948372629E-07, |
250 | 250 | 'Nmi' => 1.90484761219114E-07, |
251 | 251 | 'in' => 1.38888888888898E-02, |
@@ -255,90 +255,90 @@ discard block |
||
255 | 255 | 'Pica' => 1.0 |
256 | 256 | ) |
257 | 257 | ), |
258 | - 'Time' => array( 'yr' => array( 'yr' => 1.0, |
|
258 | + 'Time' => array('yr' => array('yr' => 1.0, |
|
259 | 259 | 'day' => 365.25, |
260 | 260 | 'hr' => 8766.0, |
261 | 261 | 'mn' => 525960.0, |
262 | 262 | 'sec' => 31557600.0 |
263 | 263 | ), |
264 | - 'day' => array( 'yr' => 2.73785078713210E-03, |
|
264 | + 'day' => array('yr' => 2.73785078713210E-03, |
|
265 | 265 | 'day' => 1.0, |
266 | 266 | 'hr' => 24.0, |
267 | 267 | 'mn' => 1440.0, |
268 | 268 | 'sec' => 86400.0 |
269 | 269 | ), |
270 | - 'hr' => array( 'yr' => 1.14077116130504E-04, |
|
270 | + 'hr' => array('yr' => 1.14077116130504E-04, |
|
271 | 271 | 'day' => 4.16666666666667E-02, |
272 | 272 | 'hr' => 1.0, |
273 | 273 | 'mn' => 60.0, |
274 | 274 | 'sec' => 3600.0 |
275 | 275 | ), |
276 | - 'mn' => array( 'yr' => 1.90128526884174E-06, |
|
276 | + 'mn' => array('yr' => 1.90128526884174E-06, |
|
277 | 277 | 'day' => 6.94444444444444E-04, |
278 | 278 | 'hr' => 1.66666666666667E-02, |
279 | 279 | 'mn' => 1.0, |
280 | 280 | 'sec' => 60.0 |
281 | 281 | ), |
282 | - 'sec' => array( 'yr' => 3.16880878140289E-08, |
|
282 | + 'sec' => array('yr' => 3.16880878140289E-08, |
|
283 | 283 | 'day' => 1.15740740740741E-05, |
284 | 284 | 'hr' => 2.77777777777778E-04, |
285 | 285 | 'mn' => 1.66666666666667E-02, |
286 | 286 | 'sec' => 1.0 |
287 | 287 | ) |
288 | 288 | ), |
289 | - 'Pressure' => array( 'Pa' => array( 'Pa' => 1.0, |
|
289 | + 'Pressure' => array('Pa' => array('Pa' => 1.0, |
|
290 | 290 | 'p' => 1.0, |
291 | 291 | 'atm' => 9.86923299998193E-06, |
292 | 292 | 'at' => 9.86923299998193E-06, |
293 | 293 | 'mmHg' => 7.50061707998627E-03 |
294 | 294 | ), |
295 | - 'p' => array( 'Pa' => 1.0, |
|
295 | + 'p' => array('Pa' => 1.0, |
|
296 | 296 | 'p' => 1.0, |
297 | 297 | 'atm' => 9.86923299998193E-06, |
298 | 298 | 'at' => 9.86923299998193E-06, |
299 | 299 | 'mmHg' => 7.50061707998627E-03 |
300 | 300 | ), |
301 | - 'atm' => array( 'Pa' => 1.01324996583000E+05, |
|
301 | + 'atm' => array('Pa' => 1.01324996583000E+05, |
|
302 | 302 | 'p' => 1.01324996583000E+05, |
303 | 303 | 'atm' => 1.0, |
304 | 304 | 'at' => 1.0, |
305 | 305 | 'mmHg' => 760.0 |
306 | 306 | ), |
307 | - 'at' => array( 'Pa' => 1.01324996583000E+05, |
|
307 | + 'at' => array('Pa' => 1.01324996583000E+05, |
|
308 | 308 | 'p' => 1.01324996583000E+05, |
309 | 309 | 'atm' => 1.0, |
310 | 310 | 'at' => 1.0, |
311 | 311 | 'mmHg' => 760.0 |
312 | 312 | ), |
313 | - 'mmHg' => array( 'Pa' => 1.33322363925000E+02, |
|
313 | + 'mmHg' => array('Pa' => 1.33322363925000E+02, |
|
314 | 314 | 'p' => 1.33322363925000E+02, |
315 | 315 | 'atm' => 1.31578947368421E-03, |
316 | 316 | 'at' => 1.31578947368421E-03, |
317 | 317 | 'mmHg' => 1.0 |
318 | 318 | ) |
319 | 319 | ), |
320 | - 'Force' => array( 'N' => array( 'N' => 1.0, |
|
320 | + 'Force' => array('N' => array('N' => 1.0, |
|
321 | 321 | 'dyn' => 1.0E+5, |
322 | 322 | 'dy' => 1.0E+5, |
323 | 323 | 'lbf' => 2.24808923655339E-01 |
324 | 324 | ), |
325 | - 'dyn' => array( 'N' => 1.0E-5, |
|
325 | + 'dyn' => array('N' => 1.0E-5, |
|
326 | 326 | 'dyn' => 1.0, |
327 | 327 | 'dy' => 1.0, |
328 | 328 | 'lbf' => 2.24808923655339E-06 |
329 | 329 | ), |
330 | - 'dy' => array( 'N' => 1.0E-5, |
|
330 | + 'dy' => array('N' => 1.0E-5, |
|
331 | 331 | 'dyn' => 1.0, |
332 | 332 | 'dy' => 1.0, |
333 | 333 | 'lbf' => 2.24808923655339E-06 |
334 | 334 | ), |
335 | - 'lbf' => array( 'N' => 4.448222, |
|
335 | + 'lbf' => array('N' => 4.448222, |
|
336 | 336 | 'dyn' => 4.448222E+5, |
337 | 337 | 'dy' => 4.448222E+5, |
338 | 338 | 'lbf' => 1.0 |
339 | 339 | ) |
340 | 340 | ), |
341 | - 'Energy' => array( 'J' => array( 'J' => 1.0, |
|
341 | + 'Energy' => array('J' => array('J' => 1.0, |
|
342 | 342 | 'e' => 9.99999519343231E+06, |
343 | 343 | 'c' => 2.39006249473467E-01, |
344 | 344 | 'cal' => 2.38846190642017E-01, |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | 'BTU' => 9.47815067349015E-04, |
353 | 353 | 'btu' => 9.47815067349015E-04 |
354 | 354 | ), |
355 | - 'e' => array( 'J' => 1.00000048065700E-07, |
|
355 | + 'e' => array('J' => 1.00000048065700E-07, |
|
356 | 356 | 'e' => 1.0, |
357 | 357 | 'c' => 2.39006364353494E-08, |
358 | 358 | 'cal' => 2.38846305445111E-08, |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | 'BTU' => 9.47815522922962E-11, |
367 | 367 | 'btu' => 9.47815522922962E-11 |
368 | 368 | ), |
369 | - 'c' => array( 'J' => 4.18399101363672E+00, |
|
369 | + 'c' => array('J' => 4.18399101363672E+00, |
|
370 | 370 | 'e' => 4.18398900257312E+07, |
371 | 371 | 'c' => 1.0, |
372 | 372 | 'cal' => 9.99330315287563E-01, |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'BTU' => 3.96564972437776E-03, |
381 | 381 | 'btu' => 3.96564972437776E-03 |
382 | 382 | ), |
383 | - 'cal' => array( 'J' => 4.18679484613929E+00, |
|
383 | + 'cal' => array('J' => 4.18679484613929E+00, |
|
384 | 384 | 'e' => 4.18679283372801E+07, |
385 | 385 | 'c' => 1.00067013349059E+00, |
386 | 386 | 'cal' => 1.0, |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | 'BTU' => 3.96830723907002E-03, |
395 | 395 | 'btu' => 3.96830723907002E-03 |
396 | 396 | ), |
397 | - 'eV' => array( 'J' => 1.60219000146921E-19, |
|
397 | + 'eV' => array('J' => 1.60219000146921E-19, |
|
398 | 398 | 'e' => 1.60218923136574E-12, |
399 | 399 | 'c' => 3.82933423195043E-20, |
400 | 400 | 'cal' => 3.82676978535648E-20, |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'BTU' => 1.51857982414846E-22, |
409 | 409 | 'btu' => 1.51857982414846E-22 |
410 | 410 | ), |
411 | - 'ev' => array( 'J' => 1.60219000146921E-19, |
|
411 | + 'ev' => array('J' => 1.60219000146921E-19, |
|
412 | 412 | 'e' => 1.60218923136574E-12, |
413 | 413 | 'c' => 3.82933423195043E-20, |
414 | 414 | 'cal' => 3.82676978535648E-20, |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | 'BTU' => 1.51857982414846E-22, |
423 | 423 | 'btu' => 1.51857982414846E-22 |
424 | 424 | ), |
425 | - 'HPh' => array( 'J' => 2.68451741316170E+06, |
|
425 | + 'HPh' => array('J' => 2.68451741316170E+06, |
|
426 | 426 | 'e' => 2.68451612283024E+13, |
427 | 427 | 'c' => 6.41616438565991E+05, |
428 | 428 | 'cal' => 6.41186757845835E+05, |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | 'BTU' => 2.54442605275546E+03, |
437 | 437 | 'btu' => 2.54442605275546E+03 |
438 | 438 | ), |
439 | - 'hh' => array( 'J' => 2.68451741316170E+06, |
|
439 | + 'hh' => array('J' => 2.68451741316170E+06, |
|
440 | 440 | 'e' => 2.68451612283024E+13, |
441 | 441 | 'c' => 6.41616438565991E+05, |
442 | 442 | 'cal' => 6.41186757845835E+05, |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | 'BTU' => 2.54442605275546E+03, |
451 | 451 | 'btu' => 2.54442605275546E+03 |
452 | 452 | ), |
453 | - 'Wh' => array( 'J' => 3.59999820554720E+03, |
|
453 | + 'Wh' => array('J' => 3.59999820554720E+03, |
|
454 | 454 | 'e' => 3.59999647518369E+10, |
455 | 455 | 'c' => 8.60422069219046E+02, |
456 | 456 | 'cal' => 8.59845857713046E+02, |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | 'BTU' => 3.41213254164705E+00, |
465 | 465 | 'btu' => 3.41213254164705E+00 |
466 | 466 | ), |
467 | - 'wh' => array( 'J' => 3.59999820554720E+03, |
|
467 | + 'wh' => array('J' => 3.59999820554720E+03, |
|
468 | 468 | 'e' => 3.59999647518369E+10, |
469 | 469 | 'c' => 8.60422069219046E+02, |
470 | 470 | 'cal' => 8.59845857713046E+02, |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | 'BTU' => 3.41213254164705E+00, |
479 | 479 | 'btu' => 3.41213254164705E+00 |
480 | 480 | ), |
481 | - 'flb' => array( 'J' => 4.21400003236424E-02, |
|
481 | + 'flb' => array('J' => 4.21400003236424E-02, |
|
482 | 482 | 'e' => 4.21399800687660E+05, |
483 | 483 | 'c' => 1.00717234301644E-02, |
484 | 484 | 'cal' => 1.00649785509554E-02, |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | 'BTU' => 3.99409272448406E-05, |
493 | 493 | 'btu' => 3.99409272448406E-05 |
494 | 494 | ), |
495 | - 'BTU' => array( 'J' => 1.05505813786749E+03, |
|
495 | + 'BTU' => array('J' => 1.05505813786749E+03, |
|
496 | 496 | 'e' => 1.05505763074665E+10, |
497 | 497 | 'c' => 2.52165488508168E+02, |
498 | 498 | 'cal' => 2.51996617135510E+02, |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | 'BTU' => 1.0, |
507 | 507 | 'btu' => 1.0, |
508 | 508 | ), |
509 | - 'btu' => array( 'J' => 1.05505813786749E+03, |
|
509 | + 'btu' => array('J' => 1.05505813786749E+03, |
|
510 | 510 | 'e' => 1.05505763074665E+10, |
511 | 511 | 'c' => 2.52165488508168E+02, |
512 | 512 | 'cal' => 2.51996617135510E+02, |
@@ -521,35 +521,35 @@ discard block |
||
521 | 521 | 'btu' => 1.0, |
522 | 522 | ) |
523 | 523 | ), |
524 | - 'Power' => array( 'HP' => array( 'HP' => 1.0, |
|
524 | + 'Power' => array('HP' => array('HP' => 1.0, |
|
525 | 525 | 'h' => 1.0, |
526 | 526 | 'W' => 7.45701000000000E+02, |
527 | 527 | 'w' => 7.45701000000000E+02 |
528 | 528 | ), |
529 | - 'h' => array( 'HP' => 1.0, |
|
529 | + 'h' => array('HP' => 1.0, |
|
530 | 530 | 'h' => 1.0, |
531 | 531 | 'W' => 7.45701000000000E+02, |
532 | 532 | 'w' => 7.45701000000000E+02 |
533 | 533 | ), |
534 | - 'W' => array( 'HP' => 1.34102006031908E-03, |
|
534 | + 'W' => array('HP' => 1.34102006031908E-03, |
|
535 | 535 | 'h' => 1.34102006031908E-03, |
536 | 536 | 'W' => 1.0, |
537 | 537 | 'w' => 1.0 |
538 | 538 | ), |
539 | - 'w' => array( 'HP' => 1.34102006031908E-03, |
|
539 | + 'w' => array('HP' => 1.34102006031908E-03, |
|
540 | 540 | 'h' => 1.34102006031908E-03, |
541 | 541 | 'W' => 1.0, |
542 | 542 | 'w' => 1.0 |
543 | 543 | ) |
544 | 544 | ), |
545 | - 'Magnetism' => array( 'T' => array( 'T' => 1.0, |
|
545 | + 'Magnetism' => array('T' => array('T' => 1.0, |
|
546 | 546 | 'ga' => 10000.0 |
547 | 547 | ), |
548 | - 'ga' => array( 'T' => 0.0001, |
|
548 | + 'ga' => array('T' => 0.0001, |
|
549 | 549 | 'ga' => 1.0 |
550 | 550 | ) |
551 | 551 | ), |
552 | - 'Liquid' => array( 'tsp' => array( 'tsp' => 1.0, |
|
552 | + 'Liquid' => array('tsp' => array('tsp' => 1.0, |
|
553 | 553 | 'tbs' => 3.33333333333333E-01, |
554 | 554 | 'oz' => 1.66666666666667E-01, |
555 | 555 | 'cup' => 2.08333333333333E-02, |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | 'l' => 4.92999408400710E-03, |
562 | 562 | 'lt' => 4.92999408400710E-03 |
563 | 563 | ), |
564 | - 'tbs' => array( 'tsp' => 3.00000000000000E+00, |
|
564 | + 'tbs' => array('tsp' => 3.00000000000000E+00, |
|
565 | 565 | 'tbs' => 1.0, |
566 | 566 | 'oz' => 5.00000000000000E-01, |
567 | 567 | 'cup' => 6.25000000000000E-02, |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | 'l' => 1.47899822520213E-02, |
574 | 574 | 'lt' => 1.47899822520213E-02 |
575 | 575 | ), |
576 | - 'oz' => array( 'tsp' => 6.00000000000000E+00, |
|
576 | + 'oz' => array('tsp' => 6.00000000000000E+00, |
|
577 | 577 | 'tbs' => 2.00000000000000E+00, |
578 | 578 | 'oz' => 1.0, |
579 | 579 | 'cup' => 1.25000000000000E-01, |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | 'l' => 2.95799645040426E-02, |
586 | 586 | 'lt' => 2.95799645040426E-02 |
587 | 587 | ), |
588 | - 'cup' => array( 'tsp' => 4.80000000000000E+01, |
|
588 | + 'cup' => array('tsp' => 4.80000000000000E+01, |
|
589 | 589 | 'tbs' => 1.60000000000000E+01, |
590 | 590 | 'oz' => 8.00000000000000E+00, |
591 | 591 | 'cup' => 1.0, |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | 'l' => 2.36639716032341E-01, |
598 | 598 | 'lt' => 2.36639716032341E-01 |
599 | 599 | ), |
600 | - 'pt' => array( 'tsp' => 9.60000000000000E+01, |
|
600 | + 'pt' => array('tsp' => 9.60000000000000E+01, |
|
601 | 601 | 'tbs' => 3.20000000000000E+01, |
602 | 602 | 'oz' => 1.60000000000000E+01, |
603 | 603 | 'cup' => 2.00000000000000E+00, |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | 'l' => 4.73279432064682E-01, |
610 | 610 | 'lt' => 4.73279432064682E-01 |
611 | 611 | ), |
612 | - 'us_pt' => array( 'tsp' => 9.60000000000000E+01, |
|
612 | + 'us_pt' => array('tsp' => 9.60000000000000E+01, |
|
613 | 613 | 'tbs' => 3.20000000000000E+01, |
614 | 614 | 'oz' => 1.60000000000000E+01, |
615 | 615 | 'cup' => 2.00000000000000E+00, |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | 'l' => 4.73279432064682E-01, |
622 | 622 | 'lt' => 4.73279432064682E-01 |
623 | 623 | ), |
624 | - 'uk_pt' => array( 'tsp' => 1.15266000000000E+02, |
|
624 | + 'uk_pt' => array('tsp' => 1.15266000000000E+02, |
|
625 | 625 | 'tbs' => 3.84220000000000E+01, |
626 | 626 | 'oz' => 1.92110000000000E+01, |
627 | 627 | 'cup' => 2.40137500000000E+00, |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | 'l' => 5.68260698087162E-01, |
634 | 634 | 'lt' => 5.68260698087162E-01 |
635 | 635 | ), |
636 | - 'qt' => array( 'tsp' => 1.92000000000000E+02, |
|
636 | + 'qt' => array('tsp' => 1.92000000000000E+02, |
|
637 | 637 | 'tbs' => 6.40000000000000E+01, |
638 | 638 | 'oz' => 3.20000000000000E+01, |
639 | 639 | 'cup' => 4.00000000000000E+00, |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | 'l' => 9.46558864129363E-01, |
646 | 646 | 'lt' => 9.46558864129363E-01 |
647 | 647 | ), |
648 | - 'gal' => array( 'tsp' => 7.68000000000000E+02, |
|
648 | + 'gal' => array('tsp' => 7.68000000000000E+02, |
|
649 | 649 | 'tbs' => 2.56000000000000E+02, |
650 | 650 | 'oz' => 1.28000000000000E+02, |
651 | 651 | 'cup' => 1.60000000000000E+01, |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | 'l' => 3.78623545651745E+00, |
658 | 658 | 'lt' => 3.78623545651745E+00 |
659 | 659 | ), |
660 | - 'l' => array( 'tsp' => 2.02840000000000E+02, |
|
660 | + 'l' => array('tsp' => 2.02840000000000E+02, |
|
661 | 661 | 'tbs' => 6.76133333333333E+01, |
662 | 662 | 'oz' => 3.38066666666667E+01, |
663 | 663 | 'cup' => 4.22583333333333E+00, |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | 'l' => 1.0, |
670 | 670 | 'lt' => 1.0 |
671 | 671 | ), |
672 | - 'lt' => array( 'tsp' => 2.02840000000000E+02, |
|
672 | + 'lt' => array('tsp' => 2.02840000000000E+02, |
|
673 | 673 | 'tbs' => 6.76133333333333E+01, |
674 | 674 | 'oz' => 3.38066666666667E+01, |
675 | 675 | 'cup' => 4.22583333333333E+00, |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | |
699 | 699 | $realNumber = $imaginary = 0; |
700 | 700 | // Extract the suffix, if there is one |
701 | - $suffix = substr($workString,-1); |
|
702 | - if (!is_numeric($suffix)) { |
|
703 | - $workString = substr($workString,0,-1); |
|
701 | + $suffix = substr($workString, -1); |
|
702 | + if ( ! is_numeric($suffix)) { |
|
703 | + $workString = substr($workString, 0, -1); |
|
704 | 704 | } else { |
705 | 705 | $suffix = ''; |
706 | 706 | } |
@@ -712,15 +712,15 @@ discard block |
||
712 | 712 | } |
713 | 713 | $power = ''; |
714 | 714 | $realNumber = strtok($workString, '+-'); |
715 | - if (strtoupper(substr($realNumber,-1)) == 'E') { |
|
715 | + if (strtoupper(substr($realNumber, -1)) == 'E') { |
|
716 | 716 | $power = strtok('+-'); |
717 | 717 | ++$leadingSign; |
718 | 718 | } |
719 | 719 | |
720 | - $realNumber = substr($workString,0,strlen($realNumber)+strlen($power)+$leadingSign); |
|
720 | + $realNumber = substr($workString, 0, strlen($realNumber) + strlen($power) + $leadingSign); |
|
721 | 721 | |
722 | 722 | if ($suffix != '') { |
723 | - $imaginary = substr($workString,strlen($realNumber)); |
|
723 | + $imaginary = substr($workString, strlen($realNumber)); |
|
724 | 724 | |
725 | 725 | if (($imaginary == '') && (($realNumber == '') || ($realNumber == '+') || ($realNumber == '-'))) { |
726 | 726 | $imaginary = $realNumber.'1'; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
736 | - return array( 'real' => $realNumber, |
|
736 | + return array('real' => $realNumber, |
|
737 | 737 | 'imaginary' => $imaginary, |
738 | 738 | 'suffix' => $suffix |
739 | 739 | ); |
@@ -749,24 +749,24 @@ discard block |
||
749 | 749 | * @return string The "cleaned" complex number |
750 | 750 | */ |
751 | 751 | private static function _cleanComplex($complexNumber) { |
752 | - if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1); |
|
753 | - if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber,1); |
|
752 | + if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber, 1); |
|
753 | + if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber, 1); |
|
754 | 754 | if ($complexNumber{0} == '.') $complexNumber = '0'.$complexNumber; |
755 | - if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1); |
|
755 | + if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber, 1); |
|
756 | 756 | return $complexNumber; |
757 | 757 | } |
758 | 758 | |
759 | 759 | |
760 | - private static function _nbrConversionFormat($xVal,$places) { |
|
761 | - if (!is_null($places)) { |
|
760 | + private static function _nbrConversionFormat($xVal, $places) { |
|
761 | + if ( ! is_null($places)) { |
|
762 | 762 | if (strlen($xVal) <= $places) { |
763 | - return substr(str_pad($xVal,$places,'0',STR_PAD_LEFT),-10); |
|
763 | + return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10); |
|
764 | 764 | } else { |
765 | 765 | return PHPExcel_Calculation_Functions::NaN(); |
766 | 766 | } |
767 | 767 | } |
768 | 768 | |
769 | - return substr($xVal,-10); |
|
769 | + return substr($xVal, -10); |
|
770 | 770 | } // function _nbrConversionFormat() |
771 | 771 | |
772 | 772 | |
@@ -792,11 +792,11 @@ discard block |
||
792 | 792 | * |
793 | 793 | */ |
794 | 794 | public static function BESSELI($x, $ord) { |
795 | - $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
796 | - $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
795 | + $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
796 | + $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
797 | 797 | |
798 | 798 | if ((is_numeric($x)) && (is_numeric($ord))) { |
799 | - $ord = floor($ord); |
|
799 | + $ord = floor($ord); |
|
800 | 800 | if ($ord < 0) { |
801 | 801 | return PHPExcel_Calculation_Functions::NaN(); |
802 | 802 | } |
@@ -846,11 +846,11 @@ discard block |
||
846 | 846 | * |
847 | 847 | */ |
848 | 848 | public static function BESSELJ($x, $ord) { |
849 | - $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
850 | - $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
849 | + $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
850 | + $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
851 | 851 | |
852 | 852 | if ((is_numeric($x)) && (is_numeric($ord))) { |
853 | - $ord = floor($ord); |
|
853 | + $ord = floor($ord); |
|
854 | 854 | if ($ord < 0) { |
855 | 855 | return PHPExcel_Calculation_Functions::NaN(); |
856 | 856 | } |
@@ -937,26 +937,26 @@ discard block |
||
937 | 937 | * |
938 | 938 | */ |
939 | 939 | public static function BESSELK($x, $ord) { |
940 | - $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
941 | - $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
940 | + $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
941 | + $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
942 | 942 | |
943 | 943 | if ((is_numeric($x)) && (is_numeric($ord))) { |
944 | 944 | if (($ord < 0) || ($x == 0.0)) { |
945 | 945 | return PHPExcel_Calculation_Functions::NaN(); |
946 | 946 | } |
947 | 947 | |
948 | - switch(floor($ord)) { |
|
948 | + switch (floor($ord)) { |
|
949 | 949 | case 0 : return self::_Besselk0($x); |
950 | 950 | break; |
951 | 951 | case 1 : return self::_Besselk1($x); |
952 | 952 | break; |
953 | - default : $fTox = 2 / $x; |
|
954 | - $fBkm = self::_Besselk0($x); |
|
955 | - $fBk = self::_Besselk1($x); |
|
953 | + default : $fTox = 2 / $x; |
|
954 | + $fBkm = self::_Besselk0($x); |
|
955 | + $fBk = self::_Besselk1($x); |
|
956 | 956 | for ($n = 1; $n < $ord; ++$n) { |
957 | 957 | $fBkp = $fBkm + $n * $fTox * $fBk; |
958 | 958 | $fBkm = $fBk; |
959 | - $fBk = $fBkp; |
|
959 | + $fBk = $fBkp; |
|
960 | 960 | } |
961 | 961 | } |
962 | 962 | return (is_nan($fBk)) ? PHPExcel_Calculation_Functions::NaN() : $fBk; |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | (-0.4237922726e7 + $y * 0.8511937935e4))))); |
991 | 991 | $f2 = 0.2499580570e14 + $y * (0.4244419664e12 + $y * (0.3733650367e10 + $y * (0.2245904002e8 + $y * |
992 | 992 | (0.1020426050e6 + $y * (0.3549632885e3 + $y))))); |
993 | - $fRet = $f1 / $f2 + 0.636619772 * ( self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum); |
|
993 | + $fRet = $f1 / $f2 + 0.636619772 * (self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum); |
|
994 | 994 | } else { |
995 | 995 | // $z = 8.0 / $fNum; |
996 | 996 | // $y = ($z * $z); |
@@ -1026,26 +1026,26 @@ discard block |
||
1026 | 1026 | * @return float |
1027 | 1027 | */ |
1028 | 1028 | public static function BESSELY($x, $ord) { |
1029 | - $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1030 | - $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
1029 | + $x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1030 | + $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord); |
|
1031 | 1031 | |
1032 | 1032 | if ((is_numeric($x)) && (is_numeric($ord))) { |
1033 | 1033 | if (($ord < 0) || ($x == 0.0)) { |
1034 | 1034 | return PHPExcel_Calculation_Functions::NaN(); |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - switch(floor($ord)) { |
|
1037 | + switch (floor($ord)) { |
|
1038 | 1038 | case 0 : return self::_Bessely0($x); |
1039 | 1039 | break; |
1040 | 1040 | case 1 : return self::_Bessely1($x); |
1041 | 1041 | break; |
1042 | - default: $fTox = 2 / $x; |
|
1043 | - $fBym = self::_Bessely0($x); |
|
1044 | - $fBy = self::_Bessely1($x); |
|
1042 | + default: $fTox = 2 / $x; |
|
1043 | + $fBym = self::_Bessely0($x); |
|
1044 | + $fBy = self::_Bessely1($x); |
|
1045 | 1045 | for ($n = 1; $n < $ord; ++$n) { |
1046 | 1046 | $fByp = $n * $fTox * $fBy - $fBym; |
1047 | 1047 | $fBym = $fBy; |
1048 | - $fBy = $fByp; |
|
1048 | + $fBy = $fByp; |
|
1049 | 1049 | } |
1050 | 1050 | } |
1051 | 1051 | return (is_nan($fBy)) ? PHPExcel_Calculation_Functions::NaN() : $fBy; |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | * @return string |
1074 | 1074 | */ |
1075 | 1075 | public static function BINTODEC($x) { |
1076 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1076 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1077 | 1077 | |
1078 | 1078 | if (is_bool($x)) { |
1079 | 1079 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1086,15 +1086,15 @@ discard block |
||
1086 | 1086 | $x = floor($x); |
1087 | 1087 | } |
1088 | 1088 | $x = (string) $x; |
1089 | - if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { |
|
1089 | + if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { |
|
1090 | 1090 | return PHPExcel_Calculation_Functions::NaN(); |
1091 | 1091 | } |
1092 | 1092 | if (strlen($x) > 10) { |
1093 | 1093 | return PHPExcel_Calculation_Functions::NaN(); |
1094 | 1094 | } elseif (strlen($x) == 10) { |
1095 | 1095 | // Two's Complement |
1096 | - $x = substr($x,-9); |
|
1097 | - return '-'.(512-bindec($x)); |
|
1096 | + $x = substr($x, -9); |
|
1097 | + return '-'.(512 - bindec($x)); |
|
1098 | 1098 | } |
1099 | 1099 | return bindec($x); |
1100 | 1100 | } // function BINTODEC() |
@@ -1124,9 +1124,9 @@ discard block |
||
1124 | 1124 | * If places is negative, BIN2HEX returns the #NUM! error value. |
1125 | 1125 | * @return string |
1126 | 1126 | */ |
1127 | - public static function BINTOHEX($x, $places=NULL) { |
|
1128 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1129 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1127 | + public static function BINTOHEX($x, $places = NULL) { |
|
1128 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1129 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1130 | 1130 | |
1131 | 1131 | if (is_bool($x)) { |
1132 | 1132 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1139,18 +1139,18 @@ discard block |
||
1139 | 1139 | $x = floor($x); |
1140 | 1140 | } |
1141 | 1141 | $x = (string) $x; |
1142 | - if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { |
|
1142 | + if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { |
|
1143 | 1143 | return PHPExcel_Calculation_Functions::NaN(); |
1144 | 1144 | } |
1145 | 1145 | if (strlen($x) > 10) { |
1146 | 1146 | return PHPExcel_Calculation_Functions::NaN(); |
1147 | 1147 | } elseif (strlen($x) == 10) { |
1148 | 1148 | // Two's Complement |
1149 | - return str_repeat('F',8).substr(strtoupper(dechex(bindec(substr($x,-9)))),-2); |
|
1149 | + return str_repeat('F', 8).substr(strtoupper(dechex(bindec(substr($x, -9)))), -2); |
|
1150 | 1150 | } |
1151 | 1151 | $hexVal = (string) strtoupper(dechex(bindec($x))); |
1152 | 1152 | |
1153 | - return self::_nbrConversionFormat($hexVal,$places); |
|
1153 | + return self::_nbrConversionFormat($hexVal, $places); |
|
1154 | 1154 | } // function BINTOHEX() |
1155 | 1155 | |
1156 | 1156 | |
@@ -1178,9 +1178,9 @@ discard block |
||
1178 | 1178 | * If places is negative, BIN2OCT returns the #NUM! error value. |
1179 | 1179 | * @return string |
1180 | 1180 | */ |
1181 | - public static function BINTOOCT($x, $places=NULL) { |
|
1182 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1183 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1181 | + public static function BINTOOCT($x, $places = NULL) { |
|
1182 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1183 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1184 | 1184 | |
1185 | 1185 | if (is_bool($x)) { |
1186 | 1186 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1193,18 +1193,18 @@ discard block |
||
1193 | 1193 | $x = floor($x); |
1194 | 1194 | } |
1195 | 1195 | $x = (string) $x; |
1196 | - if (strlen($x) > preg_match_all('/[01]/',$x,$out)) { |
|
1196 | + if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { |
|
1197 | 1197 | return PHPExcel_Calculation_Functions::NaN(); |
1198 | 1198 | } |
1199 | 1199 | if (strlen($x) > 10) { |
1200 | 1200 | return PHPExcel_Calculation_Functions::NaN(); |
1201 | 1201 | } elseif (strlen($x) == 10) { |
1202 | 1202 | // Two's Complement |
1203 | - return str_repeat('7',7).substr(strtoupper(decoct(bindec(substr($x,-9)))),-3); |
|
1203 | + return str_repeat('7', 7).substr(strtoupper(decoct(bindec(substr($x, -9)))), -3); |
|
1204 | 1204 | } |
1205 | 1205 | $octVal = (string) decoct(bindec($x)); |
1206 | 1206 | |
1207 | - return self::_nbrConversionFormat($octVal,$places); |
|
1207 | + return self::_nbrConversionFormat($octVal, $places); |
|
1208 | 1208 | } // function BINTOOCT() |
1209 | 1209 | |
1210 | 1210 | |
@@ -1236,9 +1236,9 @@ discard block |
||
1236 | 1236 | * If places is zero or negative, DEC2BIN returns the #NUM! error value. |
1237 | 1237 | * @return string |
1238 | 1238 | */ |
1239 | - public static function DECTOBIN($x, $places=NULL) { |
|
1240 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1241 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1239 | + public static function DECTOBIN($x, $places = NULL) { |
|
1240 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1241 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1242 | 1242 | |
1243 | 1243 | if (is_bool($x)) { |
1244 | 1244 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1248,19 +1248,19 @@ discard block |
||
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | $x = (string) $x; |
1251 | - if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { |
|
1251 | + if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1252 | 1252 | return PHPExcel_Calculation_Functions::VALUE(); |
1253 | 1253 | } |
1254 | 1254 | $x = (string) floor($x); |
1255 | 1255 | $r = decbin($x); |
1256 | 1256 | if (strlen($r) == 32) { |
1257 | 1257 | // Two's Complement |
1258 | - $r = substr($r,-10); |
|
1258 | + $r = substr($r, -10); |
|
1259 | 1259 | } elseif (strlen($r) > 11) { |
1260 | 1260 | return PHPExcel_Calculation_Functions::NaN(); |
1261 | 1261 | } |
1262 | 1262 | |
1263 | - return self::_nbrConversionFormat($r,$places); |
|
1263 | + return self::_nbrConversionFormat($r, $places); |
|
1264 | 1264 | } // function DECTOBIN() |
1265 | 1265 | |
1266 | 1266 | |
@@ -1292,9 +1292,9 @@ discard block |
||
1292 | 1292 | * If places is zero or negative, DEC2HEX returns the #NUM! error value. |
1293 | 1293 | * @return string |
1294 | 1294 | */ |
1295 | - public static function DECTOHEX($x, $places=null) { |
|
1296 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1297 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1295 | + public static function DECTOHEX($x, $places = null) { |
|
1296 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1297 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1298 | 1298 | |
1299 | 1299 | if (is_bool($x)) { |
1300 | 1300 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | } |
1305 | 1305 | } |
1306 | 1306 | $x = (string) $x; |
1307 | - if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { |
|
1307 | + if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1308 | 1308 | return PHPExcel_Calculation_Functions::VALUE(); |
1309 | 1309 | } |
1310 | 1310 | $x = (string) floor($x); |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | $r = 'FF'.$r; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | - return self::_nbrConversionFormat($r,$places); |
|
1317 | + return self::_nbrConversionFormat($r, $places); |
|
1318 | 1318 | } // function DECTOHEX() |
1319 | 1319 | |
1320 | 1320 | |
@@ -1346,9 +1346,9 @@ discard block |
||
1346 | 1346 | * If places is zero or negative, DEC2OCT returns the #NUM! error value. |
1347 | 1347 | * @return string |
1348 | 1348 | */ |
1349 | - public static function DECTOOCT($x, $places=null) { |
|
1350 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1351 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1349 | + public static function DECTOOCT($x, $places = null) { |
|
1350 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1351 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1352 | 1352 | |
1353 | 1353 | if (is_bool($x)) { |
1354 | 1354 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -1358,17 +1358,17 @@ discard block |
||
1358 | 1358 | } |
1359 | 1359 | } |
1360 | 1360 | $x = (string) $x; |
1361 | - if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) { |
|
1361 | + if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1362 | 1362 | return PHPExcel_Calculation_Functions::VALUE(); |
1363 | 1363 | } |
1364 | 1364 | $x = (string) floor($x); |
1365 | 1365 | $r = decoct($x); |
1366 | 1366 | if (strlen($r) == 11) { |
1367 | 1367 | // Two's Complement |
1368 | - $r = substr($r,-10); |
|
1368 | + $r = substr($r, -10); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | - return self::_nbrConversionFormat($r,$places); |
|
1371 | + return self::_nbrConversionFormat($r, $places); |
|
1372 | 1372 | } // function DECTOOCT() |
1373 | 1373 | |
1374 | 1374 | |
@@ -1403,20 +1403,20 @@ discard block |
||
1403 | 1403 | * If places is negative, HEX2BIN returns the #NUM! error value. |
1404 | 1404 | * @return string |
1405 | 1405 | */ |
1406 | - public static function HEXTOBIN($x, $places=null) { |
|
1407 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1408 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1406 | + public static function HEXTOBIN($x, $places = null) { |
|
1407 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1408 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1409 | 1409 | |
1410 | 1410 | if (is_bool($x)) { |
1411 | 1411 | return PHPExcel_Calculation_Functions::VALUE(); |
1412 | 1412 | } |
1413 | 1413 | $x = (string) $x; |
1414 | - if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { |
|
1414 | + if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { |
|
1415 | 1415 | return PHPExcel_Calculation_Functions::NaN(); |
1416 | 1416 | } |
1417 | 1417 | $binVal = decbin(hexdec($x)); |
1418 | 1418 | |
1419 | - return substr(self::_nbrConversionFormat($binVal,$places),-10); |
|
1419 | + return substr(self::_nbrConversionFormat($binVal, $places), -10); |
|
1420 | 1420 | } // function HEXTOBIN() |
1421 | 1421 | |
1422 | 1422 | |
@@ -1440,13 +1440,13 @@ discard block |
||
1440 | 1440 | * @return string |
1441 | 1441 | */ |
1442 | 1442 | public static function HEXTODEC($x) { |
1443 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1443 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1444 | 1444 | |
1445 | 1445 | if (is_bool($x)) { |
1446 | 1446 | return PHPExcel_Calculation_Functions::VALUE(); |
1447 | 1447 | } |
1448 | 1448 | $x = (string) $x; |
1449 | - if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { |
|
1449 | + if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { |
|
1450 | 1450 | return PHPExcel_Calculation_Functions::NaN(); |
1451 | 1451 | } |
1452 | 1452 | return hexdec($x); |
@@ -1485,20 +1485,20 @@ discard block |
||
1485 | 1485 | * If places is negative, HEX2OCT returns the #NUM! error value. |
1486 | 1486 | * @return string |
1487 | 1487 | */ |
1488 | - public static function HEXTOOCT($x, $places=null) { |
|
1489 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1490 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1488 | + public static function HEXTOOCT($x, $places = null) { |
|
1489 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1490 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1491 | 1491 | |
1492 | 1492 | if (is_bool($x)) { |
1493 | 1493 | return PHPExcel_Calculation_Functions::VALUE(); |
1494 | 1494 | } |
1495 | 1495 | $x = (string) $x; |
1496 | - if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { |
|
1496 | + if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { |
|
1497 | 1497 | return PHPExcel_Calculation_Functions::NaN(); |
1498 | 1498 | } |
1499 | 1499 | $octVal = decoct(hexdec($x)); |
1500 | 1500 | |
1501 | - return self::_nbrConversionFormat($octVal,$places); |
|
1501 | + return self::_nbrConversionFormat($octVal, $places); |
|
1502 | 1502 | } // function HEXTOOCT() |
1503 | 1503 | |
1504 | 1504 | |
@@ -1536,20 +1536,20 @@ discard block |
||
1536 | 1536 | * value. |
1537 | 1537 | * @return string |
1538 | 1538 | */ |
1539 | - public static function OCTTOBIN($x, $places=null) { |
|
1540 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1541 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1539 | + public static function OCTTOBIN($x, $places = null) { |
|
1540 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1541 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1542 | 1542 | |
1543 | 1543 | if (is_bool($x)) { |
1544 | 1544 | return PHPExcel_Calculation_Functions::VALUE(); |
1545 | 1545 | } |
1546 | 1546 | $x = (string) $x; |
1547 | - if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { |
|
1547 | + if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { |
|
1548 | 1548 | return PHPExcel_Calculation_Functions::NaN(); |
1549 | 1549 | } |
1550 | 1550 | $r = decbin(octdec($x)); |
1551 | 1551 | |
1552 | - return self::_nbrConversionFormat($r,$places); |
|
1552 | + return self::_nbrConversionFormat($r, $places); |
|
1553 | 1553 | } // function OCTTOBIN() |
1554 | 1554 | |
1555 | 1555 | |
@@ -1573,13 +1573,13 @@ discard block |
||
1573 | 1573 | * @return string |
1574 | 1574 | */ |
1575 | 1575 | public static function OCTTODEC($x) { |
1576 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1576 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1577 | 1577 | |
1578 | 1578 | if (is_bool($x)) { |
1579 | 1579 | return PHPExcel_Calculation_Functions::VALUE(); |
1580 | 1580 | } |
1581 | 1581 | $x = (string) $x; |
1582 | - if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { |
|
1582 | + if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { |
|
1583 | 1583 | return PHPExcel_Calculation_Functions::NaN(); |
1584 | 1584 | } |
1585 | 1585 | return octdec($x); |
@@ -1615,20 +1615,20 @@ discard block |
||
1615 | 1615 | * If places is negative, OCT2HEX returns the #NUM! error value. |
1616 | 1616 | * @return string |
1617 | 1617 | */ |
1618 | - public static function OCTTOHEX($x, $places=null) { |
|
1619 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1620 | - $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1618 | + public static function OCTTOHEX($x, $places = null) { |
|
1619 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
1620 | + $places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
|
1621 | 1621 | |
1622 | 1622 | if (is_bool($x)) { |
1623 | 1623 | return PHPExcel_Calculation_Functions::VALUE(); |
1624 | 1624 | } |
1625 | 1625 | $x = (string) $x; |
1626 | - if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { |
|
1626 | + if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { |
|
1627 | 1627 | return PHPExcel_Calculation_Functions::NaN(); |
1628 | 1628 | } |
1629 | 1629 | $hexVal = strtoupper(dechex(octdec($x))); |
1630 | 1630 | |
1631 | - return self::_nbrConversionFormat($hexVal,$places); |
|
1631 | + return self::_nbrConversionFormat($hexVal, $places); |
|
1632 | 1632 | } // function OCTTOHEX() |
1633 | 1633 | |
1634 | 1634 | |
@@ -1648,15 +1648,15 @@ discard block |
||
1648 | 1648 | * If omitted, the suffix is assumed to be "i". |
1649 | 1649 | * @return string |
1650 | 1650 | */ |
1651 | - public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix='i') { |
|
1652 | - $realNumber = (is_null($realNumber)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); |
|
1653 | - $imaginary = (is_null($imaginary)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($imaginary); |
|
1654 | - $suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix); |
|
1651 | + public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') { |
|
1652 | + $realNumber = (is_null($realNumber)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); |
|
1653 | + $imaginary = (is_null($imaginary)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($imaginary); |
|
1654 | + $suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix); |
|
1655 | 1655 | |
1656 | 1656 | if (((is_numeric($realNumber)) && (is_numeric($imaginary))) && |
1657 | 1657 | (($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) { |
1658 | - $realNumber = (float) $realNumber; |
|
1659 | - $imaginary = (float) $imaginary; |
|
1658 | + $realNumber = (float) $realNumber; |
|
1659 | + $imaginary = (float) $imaginary; |
|
1660 | 1660 | |
1661 | 1661 | if ($suffix == '') $suffix = 'i'; |
1662 | 1662 | if ($realNumber == 0.0) { |
@@ -1766,7 +1766,7 @@ discard block |
||
1766 | 1766 | if ($parsedComplex['real'] == 0.0) { |
1767 | 1767 | if ($parsedComplex['imaginary'] == 0.0) { |
1768 | 1768 | return 0.0; |
1769 | - } elseif($parsedComplex['imaginary'] < 0.0) { |
|
1769 | + } elseif ($parsedComplex['imaginary'] < 0.0) { |
|
1770 | 1770 | return M_PI / -2; |
1771 | 1771 | } else { |
1772 | 1772 | return M_PI / 2; |
@@ -1800,7 +1800,7 @@ discard block |
||
1800 | 1800 | if ($parsedComplex['imaginary'] == 0.0) { |
1801 | 1801 | return $parsedComplex['real']; |
1802 | 1802 | } else { |
1803 | - return self::_cleanComplex( self::COMPLEX( $parsedComplex['real'], |
|
1803 | + return self::_cleanComplex(self::COMPLEX($parsedComplex['real'], |
|
1804 | 1804 | 0 - $parsedComplex['imaginary'], |
1805 | 1805 | $parsedComplex['suffix'] |
1806 | 1806 | ) |
@@ -1828,7 +1828,7 @@ discard block |
||
1828 | 1828 | if ($parsedComplex['imaginary'] == 0.0) { |
1829 | 1829 | return cos($parsedComplex['real']); |
1830 | 1830 | } else { |
1831 | - return self::IMCONJUGATE(self::COMPLEX(cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']),sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix'])); |
|
1831 | + return self::IMCONJUGATE(self::COMPLEX(cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']), sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']), $parsedComplex['suffix'])); |
|
1832 | 1832 | } |
1833 | 1833 | } // function IMCOS() |
1834 | 1834 | |
@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | if ($parsedComplex['imaginary'] == 0.0) { |
1853 | 1853 | return sin($parsedComplex['real']); |
1854 | 1854 | } else { |
1855 | - return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']),cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']); |
|
1855 | + return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']), cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']), $parsedComplex['suffix']); |
|
1856 | 1856 | } |
1857 | 1857 | } // function IMSIN() |
1858 | 1858 | |
@@ -1879,9 +1879,9 @@ discard block |
||
1879 | 1879 | $r = sqrt(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']))); |
1880 | 1880 | |
1881 | 1881 | if ($parsedComplex['suffix'] == '') { |
1882 | - return self::COMPLEX($d1 * $r,$d2 * $r); |
|
1882 | + return self::COMPLEX($d1 * $r, $d2 * $r); |
|
1883 | 1883 | } else { |
1884 | - return self::COMPLEX($d1 * $r,$d2 * $r,$parsedComplex['suffix']); |
|
1884 | + return self::COMPLEX($d1 * $r, $d2 * $r, $parsedComplex['suffix']); |
|
1885 | 1885 | } |
1886 | 1886 | } // function IMSQRT() |
1887 | 1887 | |
@@ -1910,9 +1910,9 @@ discard block |
||
1910 | 1910 | $t = self::IMARGUMENT($complexNumber); |
1911 | 1911 | |
1912 | 1912 | if ($parsedComplex['suffix'] == '') { |
1913 | - return self::COMPLEX($logR,$t); |
|
1913 | + return self::COMPLEX($logR, $t); |
|
1914 | 1914 | } else { |
1915 | - return self::COMPLEX($logR,$t,$parsedComplex['suffix']); |
|
1915 | + return self::COMPLEX($logR, $t, $parsedComplex['suffix']); |
|
1916 | 1916 | } |
1917 | 1917 | } // function IMLN() |
1918 | 1918 | |
@@ -1939,7 +1939,7 @@ discard block |
||
1939 | 1939 | return log10($parsedComplex['real']); |
1940 | 1940 | } |
1941 | 1941 | |
1942 | - return self::IMPRODUCT(log10(EULER),self::IMLN($complexNumber)); |
|
1942 | + return self::IMPRODUCT(log10(EULER), self::IMLN($complexNumber)); |
|
1943 | 1943 | } // function IMLOG10() |
1944 | 1944 | |
1945 | 1945 | |
@@ -1962,10 +1962,10 @@ discard block |
||
1962 | 1962 | if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) { |
1963 | 1963 | return PHPExcel_Calculation_Functions::NaN(); |
1964 | 1964 | } elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) { |
1965 | - return log($parsedComplex['real'],2); |
|
1965 | + return log($parsedComplex['real'], 2); |
|
1966 | 1966 | } |
1967 | 1967 | |
1968 | - return self::IMPRODUCT(log(EULER,2),self::IMLN($complexNumber)); |
|
1968 | + return self::IMPRODUCT(log(EULER, 2), self::IMLN($complexNumber)); |
|
1969 | 1969 | } // function IMLOG2() |
1970 | 1970 | |
1971 | 1971 | |
@@ -1994,9 +1994,9 @@ discard block |
||
1994 | 1994 | $eY = $e * sin($parsedComplex['imaginary']); |
1995 | 1995 | |
1996 | 1996 | if ($parsedComplex['suffix'] == '') { |
1997 | - return self::COMPLEX($eX,$eY); |
|
1997 | + return self::COMPLEX($eX, $eY); |
|
1998 | 1998 | } else { |
1999 | - return self::COMPLEX($eX,$eY,$parsedComplex['suffix']); |
|
1999 | + return self::COMPLEX($eX, $eY, $parsedComplex['suffix']); |
|
2000 | 2000 | } |
2001 | 2001 | } // function IMEXP() |
2002 | 2002 | |
@@ -2013,25 +2013,25 @@ discard block |
||
2013 | 2013 | * @param float $realNumber The power to which you want to raise the complex number. |
2014 | 2014 | * @return string |
2015 | 2015 | */ |
2016 | - public static function IMPOWER($complexNumber,$realNumber) { |
|
2017 | - $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); |
|
2018 | - $realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); |
|
2016 | + public static function IMPOWER($complexNumber, $realNumber) { |
|
2017 | + $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber); |
|
2018 | + $realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber); |
|
2019 | 2019 | |
2020 | - if (!is_numeric($realNumber)) { |
|
2020 | + if ( ! is_numeric($realNumber)) { |
|
2021 | 2021 | return PHPExcel_Calculation_Functions::VALUE(); |
2022 | 2022 | } |
2023 | 2023 | |
2024 | 2024 | $parsedComplex = self::_parseComplex($complexNumber); |
2025 | 2025 | |
2026 | 2026 | $r = sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])); |
2027 | - $rPower = pow($r,$realNumber); |
|
2027 | + $rPower = pow($r, $realNumber); |
|
2028 | 2028 | $theta = self::IMARGUMENT($complexNumber) * $realNumber; |
2029 | 2029 | if ($theta == 0) { |
2030 | 2030 | return 1; |
2031 | 2031 | } elseif ($parsedComplex['imaginary'] == 0.0) { |
2032 | - return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']); |
|
2032 | + return self::COMPLEX($rPower * cos($theta), $rPower * sin($theta), $parsedComplex['suffix']); |
|
2033 | 2033 | } else { |
2034 | - return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']); |
|
2034 | + return self::COMPLEX($rPower * cos($theta), $rPower * sin($theta), $parsedComplex['suffix']); |
|
2035 | 2035 | } |
2036 | 2036 | } // function IMPOWER() |
2037 | 2037 | |
@@ -2048,9 +2048,9 @@ discard block |
||
2048 | 2048 | * @param string $complexDivisor The complex denominator or divisor. |
2049 | 2049 | * @return string |
2050 | 2050 | */ |
2051 | - public static function IMDIV($complexDividend,$complexDivisor) { |
|
2052 | - $complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend); |
|
2053 | - $complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor); |
|
2051 | + public static function IMDIV($complexDividend, $complexDivisor) { |
|
2052 | + $complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend); |
|
2053 | + $complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor); |
|
2054 | 2054 | |
2055 | 2055 | $parsedComplexDividend = self::_parseComplex($complexDividend); |
2056 | 2056 | $parsedComplexDivisor = self::_parseComplex($complexDivisor); |
@@ -2067,8 +2067,8 @@ discard block |
||
2067 | 2067 | $d2 = ($parsedComplexDividend['imaginary'] * $parsedComplexDivisor['real']) - ($parsedComplexDividend['real'] * $parsedComplexDivisor['imaginary']); |
2068 | 2068 | $d3 = ($parsedComplexDivisor['real'] * $parsedComplexDivisor['real']) + ($parsedComplexDivisor['imaginary'] * $parsedComplexDivisor['imaginary']); |
2069 | 2069 | |
2070 | - $r = $d1/$d3; |
|
2071 | - $i = $d2/$d3; |
|
2070 | + $r = $d1 / $d3; |
|
2071 | + $i = $d2 / $d3; |
|
2072 | 2072 | |
2073 | 2073 | if ($i > 0.0) { |
2074 | 2074 | return self::_cleanComplex($r.'+'.$i.$parsedComplexDivisor['suffix']); |
@@ -2092,7 +2092,7 @@ discard block |
||
2092 | 2092 | * @param string $complexNumber2 The complex number to subtract from complexNumber1. |
2093 | 2093 | * @return string |
2094 | 2094 | */ |
2095 | - public static function IMSUB($complexNumber1,$complexNumber2) { |
|
2095 | + public static function IMSUB($complexNumber1, $complexNumber2) { |
|
2096 | 2096 | $complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1); |
2097 | 2097 | $complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2); |
2098 | 2098 | |
@@ -2109,7 +2109,7 @@ discard block |
||
2109 | 2109 | $d1 = $parsedComplex1['real'] - $parsedComplex2['real']; |
2110 | 2110 | $d2 = $parsedComplex1['imaginary'] - $parsedComplex2['imaginary']; |
2111 | 2111 | |
2112 | - return self::COMPLEX($d1,$d2,$parsedComplex1['suffix']); |
|
2112 | + return self::COMPLEX($d1, $d2, $parsedComplex1['suffix']); |
|
2113 | 2113 | } // function IMSUB() |
2114 | 2114 | |
2115 | 2115 | |
@@ -2145,7 +2145,7 @@ discard block |
||
2145 | 2145 | } |
2146 | 2146 | |
2147 | 2147 | if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; } |
2148 | - return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix); |
|
2148 | + return self::COMPLEX($returnValue['real'], $returnValue['imaginary'], $activeSuffix); |
|
2149 | 2149 | } // function IMSUM() |
2150 | 2150 | |
2151 | 2151 | |
@@ -2181,7 +2181,7 @@ discard block |
||
2181 | 2181 | } |
2182 | 2182 | |
2183 | 2183 | if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; } |
2184 | - return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix); |
|
2184 | + return self::COMPLEX($returnValue['real'], $returnValue['imaginary'], $activeSuffix); |
|
2185 | 2185 | } // function IMPRODUCT() |
2186 | 2186 | |
2187 | 2187 | |
@@ -2200,7 +2200,7 @@ discard block |
||
2200 | 2200 | * @param float $b The second number. If omitted, b is assumed to be zero. |
2201 | 2201 | * @return int |
2202 | 2202 | */ |
2203 | - public static function DELTA($a, $b=0) { |
|
2203 | + public static function DELTA($a, $b = 0) { |
|
2204 | 2204 | $a = PHPExcel_Calculation_Functions::flattenSingleValue($a); |
2205 | 2205 | $b = PHPExcel_Calculation_Functions::flattenSingleValue($b); |
2206 | 2206 | |
@@ -2223,9 +2223,9 @@ discard block |
||
2223 | 2223 | * If you omit a value for step, GESTEP uses zero. |
2224 | 2224 | * @return int |
2225 | 2225 | */ |
2226 | - public static function GESTEP($number, $step=0) { |
|
2227 | - $number = PHPExcel_Calculation_Functions::flattenSingleValue($number); |
|
2228 | - $step = PHPExcel_Calculation_Functions::flattenSingleValue($step); |
|
2226 | + public static function GESTEP($number, $step = 0) { |
|
2227 | + $number = PHPExcel_Calculation_Functions::flattenSingleValue($number); |
|
2228 | + $step = PHPExcel_Calculation_Functions::flattenSingleValue($step); |
|
2229 | 2229 | |
2230 | 2230 | return (int) ($number >= $step); |
2231 | 2231 | } // function GESTEP() |
@@ -2337,7 +2337,7 @@ discard block |
||
2337 | 2337 | * @return int |
2338 | 2338 | */ |
2339 | 2339 | public static function ERFC($x) { |
2340 | - $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
2340 | + $x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
|
2341 | 2341 | |
2342 | 2342 | if (is_numeric($x)) { |
2343 | 2343 | if ($x < 0) { |
@@ -2356,7 +2356,7 @@ discard block |
||
2356 | 2356 | */ |
2357 | 2357 | public static function getConversionGroups() { |
2358 | 2358 | $conversionGroups = array(); |
2359 | - foreach(self::$_conversionUnits as $conversionUnit) { |
|
2359 | + foreach (self::$_conversionUnits as $conversionUnit) { |
|
2360 | 2360 | $conversionGroups[] = $conversionUnit['Group']; |
2361 | 2361 | } |
2362 | 2362 | return array_merge(array_unique($conversionGroups)); |
@@ -2370,7 +2370,7 @@ discard block |
||
2370 | 2370 | */ |
2371 | 2371 | public static function getConversionGroupUnits($group = NULL) { |
2372 | 2372 | $conversionGroups = array(); |
2373 | - foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) { |
|
2373 | + foreach (self::$_conversionUnits as $conversionUnit => $conversionGroup) { |
|
2374 | 2374 | if ((is_null($group)) || ($conversionGroup['Group'] == $group)) { |
2375 | 2375 | $conversionGroups[$conversionGroup['Group']][] = $conversionUnit; |
2376 | 2376 | } |
@@ -2386,9 +2386,9 @@ discard block |
||
2386 | 2386 | */ |
2387 | 2387 | public static function getConversionGroupUnitDetails($group = NULL) { |
2388 | 2388 | $conversionGroups = array(); |
2389 | - foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) { |
|
2389 | + foreach (self::$_conversionUnits as $conversionUnit => $conversionGroup) { |
|
2390 | 2390 | if ((is_null($group)) || ($conversionGroup['Group'] == $group)) { |
2391 | - $conversionGroups[$conversionGroup['Group']][] = array( 'unit' => $conversionUnit, |
|
2391 | + $conversionGroups[$conversionGroup['Group']][] = array('unit' => $conversionUnit, |
|
2392 | 2392 | 'description' => $conversionGroup['Unit Name'] |
2393 | 2393 | ); |
2394 | 2394 | } |
@@ -2424,18 +2424,18 @@ discard block |
||
2424 | 2424 | */ |
2425 | 2425 | public static function CONVERTUOM($value, $fromUOM, $toUOM) { |
2426 | 2426 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
2427 | - $fromUOM = PHPExcel_Calculation_Functions::flattenSingleValue($fromUOM); |
|
2427 | + $fromUOM = PHPExcel_Calculation_Functions::flattenSingleValue($fromUOM); |
|
2428 | 2428 | $toUOM = PHPExcel_Calculation_Functions::flattenSingleValue($toUOM); |
2429 | 2429 | |
2430 | - if (!is_numeric($value)) { |
|
2430 | + if ( ! is_numeric($value)) { |
|
2431 | 2431 | return PHPExcel_Calculation_Functions::VALUE(); |
2432 | 2432 | } |
2433 | 2433 | $fromMultiplier = 1.0; |
2434 | 2434 | if (isset(self::$_conversionUnits[$fromUOM])) { |
2435 | 2435 | $unitGroup1 = self::$_conversionUnits[$fromUOM]['Group']; |
2436 | 2436 | } else { |
2437 | - $fromMultiplier = substr($fromUOM,0,1); |
|
2438 | - $fromUOM = substr($fromUOM,1); |
|
2437 | + $fromMultiplier = substr($fromUOM, 0, 1); |
|
2438 | + $fromUOM = substr($fromUOM, 1); |
|
2439 | 2439 | if (isset(self::$_conversionMultipliers[$fromMultiplier])) { |
2440 | 2440 | $fromMultiplier = self::$_conversionMultipliers[$fromMultiplier]['multiplier']; |
2441 | 2441 | } else { |
@@ -2453,8 +2453,8 @@ discard block |
||
2453 | 2453 | if (isset(self::$_conversionUnits[$toUOM])) { |
2454 | 2454 | $unitGroup2 = self::$_conversionUnits[$toUOM]['Group']; |
2455 | 2455 | } else { |
2456 | - $toMultiplier = substr($toUOM,0,1); |
|
2457 | - $toUOM = substr($toUOM,1); |
|
2456 | + $toMultiplier = substr($toUOM, 0, 1); |
|
2457 | + $toUOM = substr($toUOM, 1); |
|
2458 | 2458 | if (isset(self::$_conversionMultipliers[$toMultiplier])) { |
2459 | 2459 | $toMultiplier = self::$_conversionMultipliers[$toMultiplier]['multiplier']; |
2460 | 2460 | } else { |
@@ -749,10 +749,18 @@ discard block |
||
749 | 749 | * @return string The "cleaned" complex number |
750 | 750 | */ |
751 | 751 | private static function _cleanComplex($complexNumber) { |
752 | - if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1); |
|
753 | - if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber,1); |
|
754 | - if ($complexNumber{0} == '.') $complexNumber = '0'.$complexNumber; |
|
755 | - if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1); |
|
752 | + if ($complexNumber{0} == '+') { |
|
753 | + $complexNumber = substr($complexNumber,1); |
|
754 | + } |
|
755 | + if ($complexNumber{0} == '0') { |
|
756 | + $complexNumber = substr($complexNumber,1); |
|
757 | + } |
|
758 | + if ($complexNumber{0} == '.') { |
|
759 | + $complexNumber = '0'.$complexNumber; |
|
760 | + } |
|
761 | + if ($complexNumber{0} == '+') { |
|
762 | + $complexNumber = substr($complexNumber,1); |
|
763 | + } |
|
756 | 764 | return $complexNumber; |
757 | 765 | } |
758 | 766 | |
@@ -1658,7 +1666,9 @@ discard block |
||
1658 | 1666 | $realNumber = (float) $realNumber; |
1659 | 1667 | $imaginary = (float) $imaginary; |
1660 | 1668 | |
1661 | - if ($suffix == '') $suffix = 'i'; |
|
1669 | + if ($suffix == '') { |
|
1670 | + $suffix = 'i'; |
|
1671 | + } |
|
1662 | 1672 | if ($realNumber == 0.0) { |
1663 | 1673 | if ($imaginary == 0.0) { |
1664 | 1674 | return (string) '0'; |
@@ -80,6 +80,10 @@ discard block |
||
80 | 80 | } // function _firstDayOfMonth() |
81 | 81 | |
82 | 82 | |
83 | + /** |
|
84 | + * @param integer $frequency |
|
85 | + * @param boolean $next |
|
86 | + */ |
|
83 | 87 | private static function _coupFirstPeriodDate($settlement, $maturity, $frequency, $next) |
84 | 88 | { |
85 | 89 | $months = 12 / $frequency; |
@@ -102,6 +106,9 @@ discard block |
||
102 | 106 | } // function _coupFirstPeriodDate() |
103 | 107 | |
104 | 108 | |
109 | + /** |
|
110 | + * @param integer $frequency |
|
111 | + */ |
|
105 | 112 | private static function _validFrequency($frequency) |
106 | 113 | { |
107 | 114 | if (($frequency == 1) || ($frequency == 2) || ($frequency == 4)) { |
@@ -179,7 +186,7 @@ discard block |
||
179 | 186 | * The security settlement date is the date after the issue date |
180 | 187 | * when the security is traded to the buyer. |
181 | 188 | * @param float $rate The security's annual coupon rate. |
182 | - * @param float $par The security's par value. |
|
189 | + * @param integer $par The security's par value. |
|
183 | 190 | * If you omit par, ACCRINT uses $1,000. |
184 | 191 | * @param integer $frequency the number of coupon payments per year. |
185 | 192 | * Valid frequency values are: |
@@ -446,6 +453,7 @@ discard block |
||
446 | 453 | * 2 Actual/360 |
447 | 454 | * 3 Actual/365 |
448 | 455 | * 4 European 30/360 |
456 | + * @param integer $frequency |
|
449 | 457 | * @return float |
450 | 458 | */ |
451 | 459 | public static function COUPDAYBS($settlement, $maturity, $frequency, $basis=0) { |
@@ -504,6 +512,7 @@ discard block |
||
504 | 512 | * 2 Actual/360 |
505 | 513 | * 3 Actual/365 |
506 | 514 | * 4 European 30/360 |
515 | + * @param integer $frequency |
|
507 | 516 | * @return float |
508 | 517 | */ |
509 | 518 | public static function COUPDAYS($settlement, $maturity, $frequency, $basis=0) { |
@@ -574,6 +583,7 @@ discard block |
||
574 | 583 | * 2 Actual/360 |
575 | 584 | * 3 Actual/365 |
576 | 585 | * 4 European 30/360 |
586 | + * @param integer $frequency |
|
577 | 587 | * @return float |
578 | 588 | */ |
579 | 589 | public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis=0) { |
@@ -689,6 +699,7 @@ discard block |
||
689 | 699 | * 2 Actual/360 |
690 | 700 | * 3 Actual/365 |
691 | 701 | * 4 European 30/360 |
702 | + * @param integer $frequency |
|
692 | 703 | * @return integer |
693 | 704 | */ |
694 | 705 | public static function COUPNUM($settlement, $maturity, $frequency, $basis=0) { |
@@ -1143,7 +1154,7 @@ discard block |
||
1143 | 1154 | * |
1144 | 1155 | * @access public |
1145 | 1156 | * @category Financial Functions |
1146 | - * @param float $nominal_rate Nominal interest rate |
|
1157 | + * @param integer $nominal_rate Nominal interest rate |
|
1147 | 1158 | * @param integer $npery Number of compounding payments per year |
1148 | 1159 | * @return float |
1149 | 1160 | */ |
@@ -1170,12 +1181,12 @@ discard block |
||
1170 | 1181 | * |
1171 | 1182 | * @access public |
1172 | 1183 | * @category Financial Functions |
1173 | - * @param float $rate The interest rate per period |
|
1184 | + * @param integer $rate The interest rate per period |
|
1174 | 1185 | * @param int $nper Total number of payment periods in an annuity |
1175 | - * @param float $pmt The payment made each period: it cannot change over the |
|
1186 | + * @param integer $pmt The payment made each period: it cannot change over the |
|
1176 | 1187 | * life of the annuity. Typically, pmt contains principal |
1177 | 1188 | * and interest but no other fees or taxes. |
1178 | - * @param float $pv Present Value, or the lump-sum amount that a series of |
|
1189 | + * @param integer $pv Present Value, or the lump-sum amount that a series of |
|
1179 | 1190 | * future payments is worth right now. |
1180 | 1191 | * @param integer $type A number 0 or 1 and indicates when payments are due: |
1181 | 1192 | * 0 or omitted At the end of the period. |
@@ -1277,7 +1288,7 @@ discard block |
||
1277 | 1288 | * @param int $per Period for which we want to find the interest |
1278 | 1289 | * @param int $nper Number of periods |
1279 | 1290 | * @param float $pv Present Value |
1280 | - * @param float $fv Future Value |
|
1291 | + * @param integer $fv Future Value |
|
1281 | 1292 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1282 | 1293 | * @return float |
1283 | 1294 | */ |
@@ -1419,7 +1430,7 @@ discard block |
||
1419 | 1430 | * |
1420 | 1431 | * Returns the nominal interest rate given the effective rate and the number of compounding payments per year. |
1421 | 1432 | * |
1422 | - * @param float $effect_rate Effective interest rate |
|
1433 | + * @param integer $effect_rate Effective interest rate |
|
1423 | 1434 | * @param int $npery Number of compounding payments per year |
1424 | 1435 | * @return float |
1425 | 1436 | */ |
@@ -1442,10 +1453,10 @@ discard block |
||
1442 | 1453 | * |
1443 | 1454 | * Returns the number of periods for a cash flow with constant periodic payments (annuities), and interest rate. |
1444 | 1455 | * |
1445 | - * @param float $rate Interest rate per period |
|
1456 | + * @param integer $rate Interest rate per period |
|
1446 | 1457 | * @param int $pmt Periodic payment (annuity) |
1447 | - * @param float $pv Present Value |
|
1448 | - * @param float $fv Future Value |
|
1458 | + * @param integer $pv Present Value |
|
1459 | + * @param integer $fv Future Value |
|
1449 | 1460 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1450 | 1461 | * @return float |
1451 | 1462 | */ |
@@ -1511,10 +1522,10 @@ discard block |
||
1511 | 1522 | * |
1512 | 1523 | * Returns the constant payment (annuity) for a cash flow with a constant interest rate. |
1513 | 1524 | * |
1514 | - * @param float $rate Interest rate per period |
|
1525 | + * @param integer $rate Interest rate per period |
|
1515 | 1526 | * @param int $nper Number of periods |
1516 | - * @param float $pv Present Value |
|
1517 | - * @param float $fv Future Value |
|
1527 | + * @param integer $pv Present Value |
|
1528 | + * @param integer $fv Future Value |
|
1518 | 1529 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1519 | 1530 | * @return float |
1520 | 1531 | */ |
@@ -1548,7 +1559,7 @@ discard block |
||
1548 | 1559 | * @param int $per Period for which we want to find the interest |
1549 | 1560 | * @param int $nper Number of periods |
1550 | 1561 | * @param float $pv Present Value |
1551 | - * @param float $fv Future Value |
|
1562 | + * @param integer $fv Future Value |
|
1552 | 1563 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1553 | 1564 | * @return float |
1554 | 1565 | */ |
@@ -1727,10 +1738,10 @@ discard block |
||
1727 | 1738 | * |
1728 | 1739 | * Returns the Present Value of a cash flow with constant payments and interest rate (annuities). |
1729 | 1740 | * |
1730 | - * @param float $rate Interest rate per period |
|
1741 | + * @param integer $rate Interest rate per period |
|
1731 | 1742 | * @param int $nper Number of periods |
1732 | - * @param float $pmt Periodic payment (annuity) |
|
1733 | - * @param float $fv Future Value |
|
1743 | + * @param integer $pmt Periodic payment (annuity) |
|
1744 | + * @param integer $fv Future Value |
|
1734 | 1745 | * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period |
1735 | 1746 | * @return float |
1736 | 1747 | */ |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * 4 European 360 |
130 | 130 | * @return integer |
131 | 131 | */ |
132 | - private static function _daysPerYear($year, $basis=0) |
|
132 | + private static function _daysPerYear($year, $basis = 0) |
|
133 | 133 | { |
134 | 134 | switch ($basis) { |
135 | 135 | case 0 : |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | } // function _daysPerYear() |
151 | 151 | |
152 | 152 | |
153 | - private static function _interestAndPrincipal($rate=0, $per=0, $nper=0, $pv=0, $fv=0, $type=0) |
|
153 | + private static function _interestAndPrincipal($rate = 0, $per = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0) |
|
154 | 154 | { |
155 | 155 | $pmt = self::PMT($rate, $nper, $pv, $fv, $type); |
156 | 156 | $capital = $pv; |
157 | - for ($i = 1; $i<= $per; ++$i) { |
|
157 | + for ($i = 1; $i <= $per; ++$i) { |
|
158 | 158 | $interest = ($type && $i == 1) ? 0 : -$capital * $rate; |
159 | 159 | $principal = $pmt - $interest; |
160 | 160 | $capital += $principal; |
@@ -198,25 +198,25 @@ discard block |
||
198 | 198 | * 4 European 30/360 |
199 | 199 | * @return float |
200 | 200 | */ |
201 | - public static function ACCRINT($issue, $firstinterest, $settlement, $rate, $par=1000, $frequency=1, $basis=0) |
|
201 | + public static function ACCRINT($issue, $firstinterest, $settlement, $rate, $par = 1000, $frequency = 1, $basis = 0) |
|
202 | 202 | { |
203 | - $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
|
204 | - $firstinterest = PHPExcel_Calculation_Functions::flattenSingleValue($firstinterest); |
|
205 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
206 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
207 | - $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par); |
|
208 | - $frequency = (is_null($frequency)) ? 1 : PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
209 | - $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
203 | + $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
|
204 | + $firstinterest = PHPExcel_Calculation_Functions::flattenSingleValue($firstinterest); |
|
205 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
206 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
207 | + $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par); |
|
208 | + $frequency = (is_null($frequency)) ? 1 : PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
209 | + $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
210 | 210 | |
211 | 211 | // Validate |
212 | 212 | if ((is_numeric($rate)) && (is_numeric($par))) { |
213 | - $rate = (float) $rate; |
|
214 | - $par = (float) $par; |
|
213 | + $rate = (float) $rate; |
|
214 | + $par = (float) $par; |
|
215 | 215 | if (($rate <= 0) || ($par <= 0)) { |
216 | 216 | return PHPExcel_Calculation_Functions::NaN(); |
217 | 217 | } |
218 | 218 | $daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis); |
219 | - if (!is_numeric($daysBetweenIssueAndSettlement)) { |
|
219 | + if ( ! is_numeric($daysBetweenIssueAndSettlement)) { |
|
220 | 220 | // return date error |
221 | 221 | return $daysBetweenIssueAndSettlement; |
222 | 222 | } |
@@ -250,22 +250,22 @@ discard block |
||
250 | 250 | * 4 European 30/360 |
251 | 251 | * @return float |
252 | 252 | */ |
253 | - public static function ACCRINTM($issue, $settlement, $rate, $par=1000, $basis=0) { |
|
254 | - $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
|
255 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
256 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
257 | - $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par); |
|
258 | - $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
253 | + public static function ACCRINTM($issue, $settlement, $rate, $par = 1000, $basis = 0) { |
|
254 | + $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
|
255 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
256 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
257 | + $par = (is_null($par)) ? 1000 : PHPExcel_Calculation_Functions::flattenSingleValue($par); |
|
258 | + $basis = (is_null($basis)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
259 | 259 | |
260 | 260 | // Validate |
261 | 261 | if ((is_numeric($rate)) && (is_numeric($par))) { |
262 | - $rate = (float) $rate; |
|
263 | - $par = (float) $par; |
|
262 | + $rate = (float) $rate; |
|
263 | + $par = (float) $par; |
|
264 | 264 | if (($rate <= 0) || ($par <= 0)) { |
265 | 265 | return PHPExcel_Calculation_Functions::NaN(); |
266 | 266 | } |
267 | 267 | $daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis); |
268 | - if (!is_numeric($daysBetweenIssueAndSettlement)) { |
|
268 | + if ( ! is_numeric($daysBetweenIssueAndSettlement)) { |
|
269 | 269 | // return date error |
270 | 270 | return $daysBetweenIssueAndSettlement; |
271 | 271 | } |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | * 4 European 30/360 |
307 | 307 | * @return float |
308 | 308 | */ |
309 | - public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0) { |
|
310 | - $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
|
311 | - $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased); |
|
312 | - $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod); |
|
309 | + public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0) { |
|
310 | + $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
|
311 | + $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased); |
|
312 | + $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod); |
|
313 | 313 | $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
314 | 314 | $period = floor(PHPExcel_Calculation_Functions::flattenSingleValue($period)); |
315 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
316 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
315 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
316 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
317 | 317 | |
318 | 318 | // The depreciation coefficients are: |
319 | 319 | // Life of assets (1/rate) Depreciation coefficient |
@@ -333,12 +333,12 @@ discard block |
||
333 | 333 | } |
334 | 334 | |
335 | 335 | $rate *= $amortiseCoeff; |
336 | - $fNRate = round(PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost,0); |
|
336 | + $fNRate = round(PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost, 0); |
|
337 | 337 | $cost -= $fNRate; |
338 | 338 | $fRest = $cost - $salvage; |
339 | 339 | |
340 | 340 | for ($n = 0; $n < $period; ++$n) { |
341 | - $fNRate = round($rate * $cost,0); |
|
341 | + $fNRate = round($rate * $cost, 0); |
|
342 | 342 | $fRest -= $fNRate; |
343 | 343 | |
344 | 344 | if ($fRest < 0.0) { |
@@ -382,14 +382,14 @@ discard block |
||
382 | 382 | * 4 European 30/360 |
383 | 383 | * @return float |
384 | 384 | */ |
385 | - public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0) { |
|
386 | - $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
|
387 | - $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased); |
|
388 | - $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod); |
|
385 | + public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0) { |
|
386 | + $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
|
387 | + $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased); |
|
388 | + $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod); |
|
389 | 389 | $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
390 | 390 | $period = PHPExcel_Calculation_Functions::flattenSingleValue($period); |
391 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
392 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
391 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
392 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
393 | 393 | |
394 | 394 | $fOneRate = $cost * $rate; |
395 | 395 | $fCostDelta = $cost - $salvage; |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | * 4 European 30/360 |
449 | 449 | * @return float |
450 | 450 | */ |
451 | - public static function COUPDAYBS($settlement, $maturity, $frequency, $basis=0) { |
|
452 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
453 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
454 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
455 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
451 | + public static function COUPDAYBS($settlement, $maturity, $frequency, $basis = 0) { |
|
452 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
453 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
454 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
455 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
456 | 456 | |
457 | 457 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
458 | 458 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | } |
463 | 463 | |
464 | 464 | if (($settlement > $maturity) || |
465 | - (!self::_validFrequency($frequency)) || |
|
465 | + ( ! self::_validFrequency($frequency)) || |
|
466 | 466 | (($basis < 0) || ($basis > 4))) { |
467 | 467 | return PHPExcel_Calculation_Functions::NaN(); |
468 | 468 | } |
469 | 469 | |
470 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
470 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
471 | 471 | $prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False); |
472 | 472 | |
473 | 473 | return PHPExcel_Calculation_DateTime::YEARFRAC($prev, $settlement, $basis) * $daysPerYear; |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | * 4 European 30/360 |
507 | 507 | * @return float |
508 | 508 | */ |
509 | - public static function COUPDAYS($settlement, $maturity, $frequency, $basis=0) { |
|
510 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
511 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
512 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
513 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
509 | + public static function COUPDAYS($settlement, $maturity, $frequency, $basis = 0) { |
|
510 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
511 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
512 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
513 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
514 | 514 | |
515 | 515 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
516 | 516 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | if (($settlement > $maturity) || |
523 | - (!self::_validFrequency($frequency)) || |
|
523 | + ( ! self::_validFrequency($frequency)) || |
|
524 | 524 | (($basis < 0) || ($basis > 4))) { |
525 | 525 | return PHPExcel_Calculation_Functions::NaN(); |
526 | 526 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | return 365 / $frequency; |
531 | 531 | case 1: // Actual/actual |
532 | 532 | if ($frequency == 1) { |
533 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($maturity),$basis); |
|
533 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($maturity), $basis); |
|
534 | 534 | return ($daysPerYear / $frequency); |
535 | 535 | } else { |
536 | 536 | $prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False); |
@@ -576,11 +576,11 @@ discard block |
||
576 | 576 | * 4 European 30/360 |
577 | 577 | * @return float |
578 | 578 | */ |
579 | - public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis=0) { |
|
580 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
581 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
582 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
583 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
579 | + public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = 0) { |
|
580 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
581 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
582 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
583 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
584 | 584 | |
585 | 585 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
586 | 586 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | } |
591 | 591 | |
592 | 592 | if (($settlement > $maturity) || |
593 | - (!self::_validFrequency($frequency)) || |
|
593 | + ( ! self::_validFrequency($frequency)) || |
|
594 | 594 | (($basis < 0) || ($basis > 4))) { |
595 | 595 | return PHPExcel_Calculation_Functions::NaN(); |
596 | 596 | } |
597 | 597 | |
598 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
598 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
599 | 599 | $next = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True); |
600 | 600 | |
601 | 601 | return PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $next, $basis) * $daysPerYear; |
@@ -635,11 +635,11 @@ discard block |
||
635 | 635 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
636 | 636 | * depending on the value of the ReturnDateType flag |
637 | 637 | */ |
638 | - public static function COUPNCD($settlement, $maturity, $frequency, $basis=0) { |
|
639 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
640 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
641 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
642 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
638 | + public static function COUPNCD($settlement, $maturity, $frequency, $basis = 0) { |
|
639 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
640 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
641 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
642 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
643 | 643 | |
644 | 644 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
645 | 645 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | } |
650 | 650 | |
651 | 651 | if (($settlement > $maturity) || |
652 | - (!self::_validFrequency($frequency)) || |
|
652 | + ( ! self::_validFrequency($frequency)) || |
|
653 | 653 | (($basis < 0) || ($basis > 4))) { |
654 | 654 | return PHPExcel_Calculation_Functions::NaN(); |
655 | 655 | } |
@@ -691,11 +691,11 @@ discard block |
||
691 | 691 | * 4 European 30/360 |
692 | 692 | * @return integer |
693 | 693 | */ |
694 | - public static function COUPNUM($settlement, $maturity, $frequency, $basis=0) { |
|
695 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
696 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
697 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
698 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
694 | + public static function COUPNUM($settlement, $maturity, $frequency, $basis = 0) { |
|
695 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
696 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
697 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
698 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
699 | 699 | |
700 | 700 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
701 | 701 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | } |
706 | 706 | |
707 | 707 | if (($settlement > $maturity) || |
708 | - (!self::_validFrequency($frequency)) || |
|
708 | + ( ! self::_validFrequency($frequency)) || |
|
709 | 709 | (($basis < 0) || ($basis > 4))) { |
710 | 710 | return PHPExcel_Calculation_Functions::NaN(); |
711 | 711 | } |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
763 | 763 | * depending on the value of the ReturnDateType flag |
764 | 764 | */ |
765 | - public static function COUPPCD($settlement, $maturity, $frequency, $basis=0) { |
|
766 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
767 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
768 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
769 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
765 | + public static function COUPPCD($settlement, $maturity, $frequency, $basis = 0) { |
|
766 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
767 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
768 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
769 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
770 | 770 | |
771 | 771 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
772 | 772 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | } |
777 | 777 | |
778 | 778 | if (($settlement > $maturity) || |
779 | - (!self::_validFrequency($frequency)) || |
|
779 | + ( ! self::_validFrequency($frequency)) || |
|
780 | 780 | (($basis < 0) || ($basis > 4))) { |
781 | 781 | return PHPExcel_Calculation_Functions::NaN(); |
782 | 782 | } |
@@ -810,9 +810,9 @@ discard block |
||
810 | 810 | $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
811 | 811 | $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper); |
812 | 812 | $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv); |
813 | - $start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start); |
|
813 | + $start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start); |
|
814 | 814 | $end = (int) PHPExcel_Calculation_Functions::flattenSingleValue($end); |
815 | - $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
815 | + $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
816 | 816 | |
817 | 817 | // Validate parameters |
818 | 818 | if ($type != 0 && $type != 1) { |
@@ -857,9 +857,9 @@ discard block |
||
857 | 857 | $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
858 | 858 | $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper); |
859 | 859 | $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv); |
860 | - $start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start); |
|
860 | + $start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start); |
|
861 | 861 | $end = (int) PHPExcel_Calculation_Functions::flattenSingleValue($end); |
862 | - $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
862 | + $type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
863 | 863 | |
864 | 864 | // Validate parameters |
865 | 865 | if ($type != 0 && $type != 1) { |
@@ -905,12 +905,12 @@ discard block |
||
905 | 905 | * it defaults to 12. |
906 | 906 | * @return float |
907 | 907 | */ |
908 | - public static function DB($cost, $salvage, $life, $period, $month=12) { |
|
908 | + public static function DB($cost, $salvage, $life, $period, $month = 12) { |
|
909 | 909 | $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
910 | 910 | $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
911 | 911 | $life = PHPExcel_Calculation_Functions::flattenSingleValue($life); |
912 | 912 | $period = PHPExcel_Calculation_Functions::flattenSingleValue($period); |
913 | - $month = PHPExcel_Calculation_Functions::flattenSingleValue($month); |
|
913 | + $month = PHPExcel_Calculation_Functions::flattenSingleValue($month); |
|
914 | 914 | |
915 | 915 | // Validate |
916 | 916 | if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period)) && (is_numeric($month))) { |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | $salvage = (float) $salvage; |
919 | 919 | $life = (int) $life; |
920 | 920 | $period = (int) $period; |
921 | - $month = (int) $month; |
|
921 | + $month = (int) $month; |
|
922 | 922 | if ($cost == 0) { |
923 | 923 | return 0.0; |
924 | 924 | } elseif (($cost < 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($month < 1)) { |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | $previousDepreciation += $depreciation; |
942 | 942 | } |
943 | 943 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { |
944 | - $depreciation = round($depreciation,2); |
|
944 | + $depreciation = round($depreciation, 2); |
|
945 | 945 | } |
946 | 946 | return $depreciation; |
947 | 947 | } |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | * double-declining balance method). |
973 | 973 | * @return float |
974 | 974 | */ |
975 | - public static function DDB($cost, $salvage, $life, $period, $factor=2.0) { |
|
975 | + public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) { |
|
976 | 976 | $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
977 | 977 | $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
978 | 978 | $life = PHPExcel_Calculation_Functions::flattenSingleValue($life); |
@@ -996,11 +996,11 @@ discard block |
||
996 | 996 | // Loop through each period calculating the depreciation |
997 | 997 | $previousDepreciation = 0; |
998 | 998 | for ($per = 1; $per <= $period; ++$per) { |
999 | - $depreciation = min( ($cost - $previousDepreciation) * ($factor / $life), ($cost - $salvage - $previousDepreciation) ); |
|
999 | + $depreciation = min(($cost - $previousDepreciation) * ($factor / $life), ($cost - $salvage - $previousDepreciation)); |
|
1000 | 1000 | $previousDepreciation += $depreciation; |
1001 | 1001 | } |
1002 | 1002 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { |
1003 | - $depreciation = round($depreciation,2); |
|
1003 | + $depreciation = round($depreciation, 2); |
|
1004 | 1004 | } |
1005 | 1005 | return $depreciation; |
1006 | 1006 | } |
@@ -1033,9 +1033,9 @@ discard block |
||
1033 | 1033 | * 4 European 30/360 |
1034 | 1034 | * @return float |
1035 | 1035 | */ |
1036 | - public static function DISC($settlement, $maturity, $price, $redemption, $basis=0) { |
|
1036 | + public static function DISC($settlement, $maturity, $price, $redemption, $basis = 0) { |
|
1037 | 1037 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
1038 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1038 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1039 | 1039 | $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
1040 | 1040 | $redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
1041 | 1041 | $basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
@@ -1043,13 +1043,13 @@ discard block |
||
1043 | 1043 | // Validate |
1044 | 1044 | if ((is_numeric($price)) && (is_numeric($redemption)) && (is_numeric($basis))) { |
1045 | 1045 | $price = (float) $price; |
1046 | - $redemption = (float) $redemption; |
|
1046 | + $redemption = (float) $redemption; |
|
1047 | 1047 | $basis = (int) $basis; |
1048 | 1048 | if (($price <= 0) || ($redemption <= 0)) { |
1049 | 1049 | return PHPExcel_Calculation_Functions::NaN(); |
1050 | 1050 | } |
1051 | 1051 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1052 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1052 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1053 | 1053 | // return date error |
1054 | 1054 | return $daysBetweenSettlementAndMaturity; |
1055 | 1055 | } |
@@ -1077,8 +1077,8 @@ discard block |
||
1077 | 1077 | * @return float |
1078 | 1078 | */ |
1079 | 1079 | public static function DOLLARDE($fractional_dollar = Null, $fraction = 0) { |
1080 | - $fractional_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($fractional_dollar); |
|
1081 | - $fraction = (int)PHPExcel_Calculation_Functions::flattenSingleValue($fraction); |
|
1080 | + $fractional_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($fractional_dollar); |
|
1081 | + $fraction = (int) PHPExcel_Calculation_Functions::flattenSingleValue($fraction); |
|
1082 | 1082 | |
1083 | 1083 | // Validate parameters |
1084 | 1084 | if (is_null($fractional_dollar) || $fraction < 0) { |
@@ -1089,9 +1089,9 @@ discard block |
||
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | $dollars = floor($fractional_dollar); |
1092 | - $cents = fmod($fractional_dollar,1); |
|
1092 | + $cents = fmod($fractional_dollar, 1); |
|
1093 | 1093 | $cents /= $fraction; |
1094 | - $cents *= pow(10,ceil(log10($fraction))); |
|
1094 | + $cents *= pow(10, ceil(log10($fraction))); |
|
1095 | 1095 | return $dollars + $cents; |
1096 | 1096 | } // function DOLLARDE() |
1097 | 1097 | |
@@ -1113,8 +1113,8 @@ discard block |
||
1113 | 1113 | * @return float |
1114 | 1114 | */ |
1115 | 1115 | public static function DOLLARFR($decimal_dollar = Null, $fraction = 0) { |
1116 | - $decimal_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($decimal_dollar); |
|
1117 | - $fraction = (int)PHPExcel_Calculation_Functions::flattenSingleValue($fraction); |
|
1116 | + $decimal_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($decimal_dollar); |
|
1117 | + $fraction = (int) PHPExcel_Calculation_Functions::flattenSingleValue($fraction); |
|
1118 | 1118 | |
1119 | 1119 | // Validate parameters |
1120 | 1120 | if (is_null($decimal_dollar) || $fraction < 0) { |
@@ -1125,9 +1125,9 @@ discard block |
||
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | $dollars = floor($decimal_dollar); |
1128 | - $cents = fmod($decimal_dollar,1); |
|
1128 | + $cents = fmod($decimal_dollar, 1); |
|
1129 | 1129 | $cents *= $fraction; |
1130 | - $cents *= pow(10,-ceil(log10($fraction))); |
|
1130 | + $cents *= pow(10, -ceil(log10($fraction))); |
|
1131 | 1131 | return $dollars + $cents; |
1132 | 1132 | } // function DOLLARFR() |
1133 | 1133 | |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | * @return float |
1149 | 1149 | */ |
1150 | 1150 | public static function EFFECT($nominal_rate = 0, $npery = 0) { |
1151 | - $nominal_rate = PHPExcel_Calculation_Functions::flattenSingleValue($nominal_rate); |
|
1152 | - $npery = (int)PHPExcel_Calculation_Functions::flattenSingleValue($npery); |
|
1151 | + $nominal_rate = PHPExcel_Calculation_Functions::flattenSingleValue($nominal_rate); |
|
1152 | + $npery = (int) PHPExcel_Calculation_Functions::flattenSingleValue($npery); |
|
1153 | 1153 | |
1154 | 1154 | // Validate parameters |
1155 | 1155 | if ($nominal_rate <= 0 || $npery < 1) { |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | // Calculate |
1198 | - if (!is_null($rate) && $rate != 0) { |
|
1198 | + if ( ! is_null($rate) && $rate != 0) { |
|
1199 | 1199 | return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate; |
1200 | 1200 | } else { |
1201 | 1201 | return -$pv - $pmt * $nper; |
@@ -1208,10 +1208,10 @@ discard block |
||
1208 | 1208 | * |
1209 | 1209 | */ |
1210 | 1210 | public static function FVSCHEDULE($principal, $schedule) { |
1211 | - $principal = PHPExcel_Calculation_Functions::flattenSingleValue($principal); |
|
1212 | - $schedule = PHPExcel_Calculation_Functions::flattenArray($schedule); |
|
1211 | + $principal = PHPExcel_Calculation_Functions::flattenSingleValue($principal); |
|
1212 | + $schedule = PHPExcel_Calculation_Functions::flattenArray($schedule); |
|
1213 | 1213 | |
1214 | - foreach($schedule as $n) { |
|
1214 | + foreach ($schedule as $n) { |
|
1215 | 1215 | $principal *= 1 + $n; |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1241,23 +1241,23 @@ discard block |
||
1241 | 1241 | * 4 European 30/360 |
1242 | 1242 | * @return float |
1243 | 1243 | */ |
1244 | - public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis=0) { |
|
1244 | + public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis = 0) { |
|
1245 | 1245 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
1246 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1246 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1247 | 1247 | $investment = PHPExcel_Calculation_Functions::flattenSingleValue($investment); |
1248 | 1248 | $redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
1249 | - $basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1249 | + $basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1250 | 1250 | |
1251 | 1251 | // Validate |
1252 | 1252 | if ((is_numeric($investment)) && (is_numeric($redemption)) && (is_numeric($basis))) { |
1253 | 1253 | $investment = (float) $investment; |
1254 | 1254 | $redemption = (float) $redemption; |
1255 | - $basis = (int) $basis; |
|
1255 | + $basis = (int) $basis; |
|
1256 | 1256 | if (($investment <= 0) || ($redemption <= 0)) { |
1257 | 1257 | return PHPExcel_Calculation_Functions::NaN(); |
1258 | 1258 | } |
1259 | 1259 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1260 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1260 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1261 | 1261 | // return date error |
1262 | 1262 | return $daysBetweenSettlementAndMaturity; |
1263 | 1263 | } |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | |
1305 | 1305 | |
1306 | 1306 | public static function IRR($values, $guess = 0.1) { |
1307 | - if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1307 | + if ( ! is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1308 | 1308 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
1309 | 1309 | $guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
1310 | 1310 | |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | $dx = $x1 - $x2; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | - for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
|
1335 | + for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
|
1336 | 1336 | $dx *= 0.5; |
1337 | 1337 | $x_mid = $rtb + $dx; |
1338 | 1338 | $f_mid = self::NPV($x_mid, $values); |
@@ -1372,11 +1372,11 @@ discard block |
||
1372 | 1372 | |
1373 | 1373 | // Calculate |
1374 | 1374 | $principlePayment = ($principleRemaining * 1.0) / ($numberPeriods * 1.0); |
1375 | - for($i=0; $i <= $period; ++$i) { |
|
1375 | + for ($i = 0; $i <= $period; ++$i) { |
|
1376 | 1376 | $returnValue = $interestRate * $principleRemaining * -1; |
1377 | 1377 | $principleRemaining -= $principlePayment; |
1378 | 1378 | // principle needs to be 0 after the last payment, don't let floating point screw it up |
1379 | - if($i == $numberPeriods) { |
|
1379 | + if ($i == $numberPeriods) { |
|
1380 | 1380 | $returnValue = 0; |
1381 | 1381 | } |
1382 | 1382 | } |
@@ -1385,17 +1385,17 @@ discard block |
||
1385 | 1385 | |
1386 | 1386 | |
1387 | 1387 | public static function MIRR($values, $finance_rate, $reinvestment_rate) { |
1388 | - if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1389 | - $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
1390 | - $finance_rate = PHPExcel_Calculation_Functions::flattenSingleValue($finance_rate); |
|
1391 | - $reinvestment_rate = PHPExcel_Calculation_Functions::flattenSingleValue($reinvestment_rate); |
|
1388 | + if ( ! is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1389 | + $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
1390 | + $finance_rate = PHPExcel_Calculation_Functions::flattenSingleValue($finance_rate); |
|
1391 | + $reinvestment_rate = PHPExcel_Calculation_Functions::flattenSingleValue($reinvestment_rate); |
|
1392 | 1392 | $n = count($values); |
1393 | 1393 | |
1394 | 1394 | $rr = 1.0 + $reinvestment_rate; |
1395 | 1395 | $fr = 1.0 + $finance_rate; |
1396 | 1396 | |
1397 | 1397 | $npv_pos = $npv_neg = 0.0; |
1398 | - foreach($values as $i => $v) { |
|
1398 | + foreach ($values as $i => $v) { |
|
1399 | 1399 | if ($v >= 0) { |
1400 | 1400 | $npv_pos += $v / pow($rr, $i); |
1401 | 1401 | } else { |
@@ -1424,8 +1424,8 @@ discard block |
||
1424 | 1424 | * @return float |
1425 | 1425 | */ |
1426 | 1426 | public static function NOMINAL($effect_rate = 0, $npery = 0) { |
1427 | - $effect_rate = PHPExcel_Calculation_Functions::flattenSingleValue($effect_rate); |
|
1428 | - $npery = (int)PHPExcel_Calculation_Functions::flattenSingleValue($npery); |
|
1427 | + $effect_rate = PHPExcel_Calculation_Functions::flattenSingleValue($effect_rate); |
|
1428 | + $npery = (int) PHPExcel_Calculation_Functions::flattenSingleValue($npery); |
|
1429 | 1429 | |
1430 | 1430 | // Validate parameters |
1431 | 1431 | if ($effect_rate <= 0 || $npery < 1) { |
@@ -1450,11 +1450,11 @@ discard block |
||
1450 | 1450 | * @return float |
1451 | 1451 | */ |
1452 | 1452 | public static function NPER($rate = 0, $pmt = 0, $pv = 0, $fv = 0, $type = 0) { |
1453 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1453 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1454 | 1454 | $pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt); |
1455 | 1455 | $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv); |
1456 | 1456 | $fv = PHPExcel_Calculation_Functions::flattenSingleValue($fv); |
1457 | - $type = PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
1457 | + $type = PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
1458 | 1458 | |
1459 | 1459 | // Validate parameters |
1460 | 1460 | if ($type != 0 && $type != 1) { |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | // Calculate |
1465 | - if (!is_null($rate) && $rate != 0) { |
|
1465 | + if ( ! is_null($rate) && $rate != 0) { |
|
1466 | 1466 | if ($pmt == 0 && $pv == 0) { |
1467 | 1467 | return PHPExcel_Calculation_Functions::NaN(); |
1468 | 1468 | } |
@@ -1471,7 +1471,7 @@ discard block |
||
1471 | 1471 | if ($pmt == 0) { |
1472 | 1472 | return PHPExcel_Calculation_Functions::NaN(); |
1473 | 1473 | } |
1474 | - return (-$pv -$fv) / $pmt; |
|
1474 | + return (-$pv - $fv) / $pmt; |
|
1475 | 1475 | } |
1476 | 1476 | } // function NPER() |
1477 | 1477 | |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | // Calculate |
1534 | - if (!is_null($rate) && $rate != 0) { |
|
1534 | + if ( ! is_null($rate) && $rate != 0) { |
|
1535 | 1535 | return (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate); |
1536 | 1536 | } else { |
1537 | 1537 | return (-$pv - $fv) / $nper; |
@@ -1574,14 +1574,14 @@ discard block |
||
1574 | 1574 | } // function PPMT() |
1575 | 1575 | |
1576 | 1576 | |
1577 | - public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis=0) { |
|
1578 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1579 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1580 | - $rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1577 | + public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis = 0) { |
|
1578 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1579 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1580 | + $rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1581 | 1581 | $yield = (float) PHPExcel_Calculation_Functions::flattenSingleValue($yield); |
1582 | - $redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
|
1583 | - $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
1584 | - $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1582 | + $redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
|
1583 | + $frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency); |
|
1584 | + $basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1585 | 1585 | |
1586 | 1586 | if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) { |
1587 | 1587 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -1591,7 +1591,7 @@ discard block |
||
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | if (($settlement > $maturity) || |
1594 | - (!self::_validFrequency($frequency)) || |
|
1594 | + ( ! self::_validFrequency($frequency)) || |
|
1595 | 1595 | (($basis < 0) || ($basis > 4))) { |
1596 | 1596 | return PHPExcel_Calculation_Functions::NaN(); |
1597 | 1597 | } |
@@ -1601,12 +1601,12 @@ discard block |
||
1601 | 1601 | $n = self::COUPNUM($settlement, $maturity, $frequency, $basis); |
1602 | 1602 | $a = self::COUPDAYBS($settlement, $maturity, $frequency, $basis); |
1603 | 1603 | |
1604 | - $baseYF = 1.0 + ($yield / $frequency); |
|
1605 | - $rfp = 100 * ($rate / $frequency); |
|
1606 | - $de = $dsc / $e; |
|
1604 | + $baseYF = 1.0 + ($yield / $frequency); |
|
1605 | + $rfp = 100 * ($rate / $frequency); |
|
1606 | + $de = $dsc / $e; |
|
1607 | 1607 | |
1608 | 1608 | $result = $redemption / pow($baseYF, (--$n + $de)); |
1609 | - for($k = 0; $k <= $n; ++$k) { |
|
1609 | + for ($k = 0; $k <= $n; ++$k) { |
|
1610 | 1610 | $result += $rfp / (pow($baseYF, ($k + $de))); |
1611 | 1611 | } |
1612 | 1612 | $result -= $rfp * ($a / $e); |
@@ -1634,12 +1634,12 @@ discard block |
||
1634 | 1634 | * 4 European 30/360 |
1635 | 1635 | * @return float |
1636 | 1636 | */ |
1637 | - public static function PRICEDISC($settlement, $maturity, $discount, $redemption, $basis=0) { |
|
1637 | + public static function PRICEDISC($settlement, $maturity, $discount, $redemption, $basis = 0) { |
|
1638 | 1638 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
1639 | 1639 | $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
1640 | 1640 | $discount = (float) PHPExcel_Calculation_Functions::flattenSingleValue($discount); |
1641 | 1641 | $redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
1642 | - $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1642 | + $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1643 | 1643 | |
1644 | 1644 | // Validate |
1645 | 1645 | if ((is_numeric($discount)) && (is_numeric($redemption)) && (is_numeric($basis))) { |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | return PHPExcel_Calculation_Functions::NaN(); |
1648 | 1648 | } |
1649 | 1649 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1650 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1650 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1651 | 1651 | // return date error |
1652 | 1652 | return $daysBetweenSettlementAndMaturity; |
1653 | 1653 | } |
@@ -1678,11 +1678,11 @@ discard block |
||
1678 | 1678 | * 4 European 30/360 |
1679 | 1679 | * @return float |
1680 | 1680 | */ |
1681 | - public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $basis=0) { |
|
1682 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1683 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1681 | + public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $basis = 0) { |
|
1682 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1683 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
1684 | 1684 | $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
1685 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1685 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
1686 | 1686 | $yield = PHPExcel_Calculation_Functions::flattenSingleValue($yield); |
1687 | 1687 | $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
1688 | 1688 | |
@@ -1691,24 +1691,24 @@ discard block |
||
1691 | 1691 | if (($rate <= 0) || ($yield <= 0)) { |
1692 | 1692 | return PHPExcel_Calculation_Functions::NaN(); |
1693 | 1693 | } |
1694 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
1695 | - if (!is_numeric($daysPerYear)) { |
|
1694 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
1695 | + if ( ! is_numeric($daysPerYear)) { |
|
1696 | 1696 | return $daysPerYear; |
1697 | 1697 | } |
1698 | 1698 | $daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis); |
1699 | - if (!is_numeric($daysBetweenIssueAndSettlement)) { |
|
1699 | + if ( ! is_numeric($daysBetweenIssueAndSettlement)) { |
|
1700 | 1700 | // return date error |
1701 | 1701 | return $daysBetweenIssueAndSettlement; |
1702 | 1702 | } |
1703 | 1703 | $daysBetweenIssueAndSettlement *= $daysPerYear; |
1704 | 1704 | $daysBetweenIssueAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $maturity, $basis); |
1705 | - if (!is_numeric($daysBetweenIssueAndMaturity)) { |
|
1705 | + if ( ! is_numeric($daysBetweenIssueAndMaturity)) { |
|
1706 | 1706 | // return date error |
1707 | 1707 | return $daysBetweenIssueAndMaturity; |
1708 | 1708 | } |
1709 | 1709 | $daysBetweenIssueAndMaturity *= $daysPerYear; |
1710 | 1710 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1711 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1711 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1712 | 1712 | // return date error |
1713 | 1713 | return $daysBetweenSettlementAndMaturity; |
1714 | 1714 | } |
@@ -1747,7 +1747,7 @@ discard block |
||
1747 | 1747 | } |
1748 | 1748 | |
1749 | 1749 | // Calculate |
1750 | - if (!is_null($rate) && $rate != 0) { |
|
1750 | + if ( ! is_null($rate) && $rate != 0) { |
|
1751 | 1751 | return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper); |
1752 | 1752 | } else { |
1753 | 1753 | return -$fv - $pmt * $nper; |
@@ -1786,12 +1786,12 @@ discard block |
||
1786 | 1786 | * @return float |
1787 | 1787 | **/ |
1788 | 1788 | public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1) { |
1789 | - $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper); |
|
1789 | + $nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper); |
|
1790 | 1790 | $pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt); |
1791 | 1791 | $pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv); |
1792 | - $fv = (is_null($fv)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($fv); |
|
1793 | - $type = (is_null($type)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
1794 | - $guess = (is_null($guess)) ? 0.1 : PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
|
1792 | + $fv = (is_null($fv)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($fv); |
|
1793 | + $type = (is_null($type)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($type); |
|
1794 | + $guess = (is_null($guess)) ? 0.1 : PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
|
1795 | 1795 | |
1796 | 1796 | $rate = $guess; |
1797 | 1797 | if (abs($rate) < FINANCIAL_PRECISION) { |
@@ -1847,12 +1847,12 @@ discard block |
||
1847 | 1847 | * 4 European 30/360 |
1848 | 1848 | * @return float |
1849 | 1849 | */ |
1850 | - public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis=0) { |
|
1850 | + public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis = 0) { |
|
1851 | 1851 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
1852 | 1852 | $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
1853 | 1853 | $investment = (float) PHPExcel_Calculation_Functions::flattenSingleValue($investment); |
1854 | 1854 | $discount = (float) PHPExcel_Calculation_Functions::flattenSingleValue($discount); |
1855 | - $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1855 | + $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
|
1856 | 1856 | |
1857 | 1857 | // Validate |
1858 | 1858 | if ((is_numeric($investment)) && (is_numeric($discount)) && (is_numeric($basis))) { |
@@ -1860,12 +1860,12 @@ discard block |
||
1860 | 1860 | return PHPExcel_Calculation_Functions::NaN(); |
1861 | 1861 | } |
1862 | 1862 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
1863 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1863 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1864 | 1864 | // return date error |
1865 | 1865 | return $daysBetweenSettlementAndMaturity; |
1866 | 1866 | } |
1867 | 1867 | |
1868 | - return $investment / ( 1 - ($discount * $daysBetweenSettlementAndMaturity)); |
|
1868 | + return $investment / (1 - ($discount * $daysBetweenSettlementAndMaturity)); |
|
1869 | 1869 | } |
1870 | 1870 | return PHPExcel_Calculation_Functions::VALUE(); |
1871 | 1871 | } // function RECEIVED() |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | */ |
1884 | 1884 | public static function SLN($cost, $salvage, $life) { |
1885 | 1885 | $cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost); |
1886 | - $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
|
1886 | + $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage); |
|
1887 | 1887 | $life = PHPExcel_Calculation_Functions::flattenSingleValue($life); |
1888 | 1888 | |
1889 | 1889 | // Calculate |
@@ -1938,7 +1938,7 @@ discard block |
||
1938 | 1938 | * @return float |
1939 | 1939 | */ |
1940 | 1940 | public static function TBILLEQ($settlement, $maturity, $discount) { |
1941 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1941 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1942 | 1942 | $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
1943 | 1943 | $discount = PHPExcel_Calculation_Functions::flattenSingleValue($discount); |
1944 | 1944 | |
@@ -1976,7 +1976,7 @@ discard block |
||
1976 | 1976 | * @return float |
1977 | 1977 | */ |
1978 | 1978 | public static function TBILLPRICE($settlement, $maturity, $discount) { |
1979 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1979 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
1980 | 1980 | $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
1981 | 1981 | $discount = PHPExcel_Calculation_Functions::flattenSingleValue($discount); |
1982 | 1982 | |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
1994 | 1994 | ++$maturity; |
1995 | 1995 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity) * 360; |
1996 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1996 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
1997 | 1997 | // return date error |
1998 | 1998 | return $daysBetweenSettlementAndMaturity; |
1999 | 1999 | } |
@@ -2028,9 +2028,9 @@ discard block |
||
2028 | 2028 | * @return float |
2029 | 2029 | */ |
2030 | 2030 | public static function TBILLYIELD($settlement, $maturity, $price) { |
2031 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
2032 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2033 | - $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
|
2031 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
2032 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2033 | + $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
|
2034 | 2034 | |
2035 | 2035 | // Validate |
2036 | 2036 | if (is_numeric($price)) { |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
2042 | 2042 | ++$maturity; |
2043 | 2043 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity) * 360; |
2044 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2044 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2045 | 2045 | // return date error |
2046 | 2046 | return $daysBetweenSettlementAndMaturity; |
2047 | 2047 | } |
@@ -2060,8 +2060,8 @@ discard block |
||
2060 | 2060 | |
2061 | 2061 | |
2062 | 2062 | public static function XIRR($values, $dates, $guess = 0.1) { |
2063 | - if ((!is_array($values)) && (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2064 | - $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
2063 | + if (( ! is_array($values)) && ( ! is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2064 | + $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
2065 | 2065 | $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
2066 | 2066 | $guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
2067 | 2067 | if (count($values) != count($dates)) return PHPExcel_Calculation_Functions::NaN(); |
@@ -2090,7 +2090,7 @@ discard block |
||
2090 | 2090 | $dx = $x1 - $x2; |
2091 | 2091 | } |
2092 | 2092 | |
2093 | - for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
|
2093 | + for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
|
2094 | 2094 | $dx *= 0.5; |
2095 | 2095 | $x_mid = $rtb + $dx; |
2096 | 2096 | $f_mid = self::XNPV($x_mid, $values, $dates); |
@@ -2117,18 +2117,18 @@ discard block |
||
2117 | 2117 | */ |
2118 | 2118 | public static function XNPV($rate, $values, $dates) { |
2119 | 2119 | $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
2120 | - if (!is_numeric($rate)) return PHPExcel_Calculation_Functions::VALUE(); |
|
2121 | - if ((!is_array($values)) || (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2122 | - $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
2123 | - $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
|
2120 | + if ( ! is_numeric($rate)) return PHPExcel_Calculation_Functions::VALUE(); |
|
2121 | + if (( ! is_array($values)) || ( ! is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2122 | + $values = PHPExcel_Calculation_Functions::flattenArray($values); |
|
2123 | + $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
|
2124 | 2124 | $valCount = count($values); |
2125 | 2125 | if ($valCount != count($dates)) return PHPExcel_Calculation_Functions::NaN(); |
2126 | 2126 | if ((min($values) > 0) || (max($values) < 0)) return PHPExcel_Calculation_Functions::VALUE(); |
2127 | 2127 | |
2128 | 2128 | $xnpv = 0.0; |
2129 | 2129 | for ($i = 0; $i < $valCount; ++$i) { |
2130 | - if (!is_numeric($values[$i])) return PHPExcel_Calculation_Functions::VALUE(); |
|
2131 | - $xnpv += $values[$i] / pow(1 + $rate, PHPExcel_Calculation_DateTime::DATEDIF($dates[0],$dates[$i],'d') / 365); |
|
2130 | + if ( ! is_numeric($values[$i])) return PHPExcel_Calculation_Functions::VALUE(); |
|
2131 | + $xnpv += $values[$i] / pow(1 + $rate, PHPExcel_Calculation_DateTime::DATEDIF($dates[0], $dates[$i], 'd') / 365); |
|
2132 | 2132 | } |
2133 | 2133 | return (is_finite($xnpv)) ? $xnpv : PHPExcel_Calculation_Functions::VALUE(); |
2134 | 2134 | } // function XNPV() |
@@ -2153,9 +2153,9 @@ discard block |
||
2153 | 2153 | * 4 European 30/360 |
2154 | 2154 | * @return float |
2155 | 2155 | */ |
2156 | - public static function YIELDDISC($settlement, $maturity, $price, $redemption, $basis=0) { |
|
2156 | + public static function YIELDDISC($settlement, $maturity, $price, $redemption, $basis = 0) { |
|
2157 | 2157 | $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
2158 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2158 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2159 | 2159 | $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
2160 | 2160 | $redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption); |
2161 | 2161 | $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
@@ -2165,12 +2165,12 @@ discard block |
||
2165 | 2165 | if (($price <= 0) || ($redemption <= 0)) { |
2166 | 2166 | return PHPExcel_Calculation_Functions::NaN(); |
2167 | 2167 | } |
2168 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
2169 | - if (!is_numeric($daysPerYear)) { |
|
2168 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
2169 | + if ( ! is_numeric($daysPerYear)) { |
|
2170 | 2170 | return $daysPerYear; |
2171 | 2171 | } |
2172 | - $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity,$basis); |
|
2173 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2172 | + $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
|
2173 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2174 | 2174 | // return date error |
2175 | 2175 | return $daysBetweenSettlementAndMaturity; |
2176 | 2176 | } |
@@ -2202,11 +2202,11 @@ discard block |
||
2202 | 2202 | * 4 European 30/360 |
2203 | 2203 | * @return float |
2204 | 2204 | */ |
2205 | - public static function YIELDMAT($settlement, $maturity, $issue, $rate, $price, $basis=0) { |
|
2206 | - $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
2207 | - $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2205 | + public static function YIELDMAT($settlement, $maturity, $issue, $rate, $price, $basis = 0) { |
|
2206 | + $settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement); |
|
2207 | + $maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity); |
|
2208 | 2208 | $issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue); |
2209 | - $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
2209 | + $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
|
2210 | 2210 | $price = PHPExcel_Calculation_Functions::flattenSingleValue($price); |
2211 | 2211 | $basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis); |
2212 | 2212 | |
@@ -2215,24 +2215,24 @@ discard block |
||
2215 | 2215 | if (($rate <= 0) || ($price <= 0)) { |
2216 | 2216 | return PHPExcel_Calculation_Functions::NaN(); |
2217 | 2217 | } |
2218 | - $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis); |
|
2219 | - if (!is_numeric($daysPerYear)) { |
|
2218 | + $daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement), $basis); |
|
2219 | + if ( ! is_numeric($daysPerYear)) { |
|
2220 | 2220 | return $daysPerYear; |
2221 | 2221 | } |
2222 | 2222 | $daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis); |
2223 | - if (!is_numeric($daysBetweenIssueAndSettlement)) { |
|
2223 | + if ( ! is_numeric($daysBetweenIssueAndSettlement)) { |
|
2224 | 2224 | // return date error |
2225 | 2225 | return $daysBetweenIssueAndSettlement; |
2226 | 2226 | } |
2227 | 2227 | $daysBetweenIssueAndSettlement *= $daysPerYear; |
2228 | 2228 | $daysBetweenIssueAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $maturity, $basis); |
2229 | - if (!is_numeric($daysBetweenIssueAndMaturity)) { |
|
2229 | + if ( ! is_numeric($daysBetweenIssueAndMaturity)) { |
|
2230 | 2230 | // return date error |
2231 | 2231 | return $daysBetweenIssueAndMaturity; |
2232 | 2232 | } |
2233 | 2233 | $daysBetweenIssueAndMaturity *= $daysPerYear; |
2234 | 2234 | $daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis); |
2235 | - if (!is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2235 | + if ( ! is_numeric($daysBetweenSettlementAndMaturity)) { |
|
2236 | 2236 | // return date error |
2237 | 2237 | return $daysBetweenSettlementAndMaturity; |
2238 | 2238 | } |
@@ -1304,7 +1304,9 @@ discard block |
||
1304 | 1304 | |
1305 | 1305 | |
1306 | 1306 | public static function IRR($values, $guess = 0.1) { |
1307 | - if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1307 | + if (!is_array($values)) { |
|
1308 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
1309 | + } |
|
1308 | 1310 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
1309 | 1311 | $guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
1310 | 1312 | |
@@ -1314,14 +1316,18 @@ discard block |
||
1314 | 1316 | $f1 = self::NPV($x1, $values); |
1315 | 1317 | $f2 = self::NPV($x2, $values); |
1316 | 1318 | for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
1317 | - if (($f1 * $f2) < 0.0) break; |
|
1319 | + if (($f1 * $f2) < 0.0) { |
|
1320 | + break; |
|
1321 | + } |
|
1318 | 1322 | if (abs($f1) < abs($f2)) { |
1319 | 1323 | $f1 = self::NPV($x1 += 1.6 * ($x1 - $x2), $values); |
1320 | 1324 | } else { |
1321 | 1325 | $f2 = self::NPV($x2 += 1.6 * ($x2 - $x1), $values); |
1322 | 1326 | } |
1323 | 1327 | } |
1324 | - if (($f1 * $f2) > 0.0) return PHPExcel_Calculation_Functions::VALUE(); |
|
1328 | + if (($f1 * $f2) > 0.0) { |
|
1329 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
1330 | + } |
|
1325 | 1331 | |
1326 | 1332 | $f = self::NPV($x1, $values); |
1327 | 1333 | if ($f < 0.0) { |
@@ -1336,8 +1342,12 @@ discard block |
||
1336 | 1342 | $dx *= 0.5; |
1337 | 1343 | $x_mid = $rtb + $dx; |
1338 | 1344 | $f_mid = self::NPV($x_mid, $values); |
1339 | - if ($f_mid <= 0.0) $rtb = $x_mid; |
|
1340 | - if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) return $x_mid; |
|
1345 | + if ($f_mid <= 0.0) { |
|
1346 | + $rtb = $x_mid; |
|
1347 | + } |
|
1348 | + if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) { |
|
1349 | + return $x_mid; |
|
1350 | + } |
|
1341 | 1351 | } |
1342 | 1352 | return PHPExcel_Calculation_Functions::VALUE(); |
1343 | 1353 | } // function IRR() |
@@ -1385,7 +1395,9 @@ discard block |
||
1385 | 1395 | |
1386 | 1396 | |
1387 | 1397 | public static function MIRR($values, $finance_rate, $reinvestment_rate) { |
1388 | - if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE(); |
|
1398 | + if (!is_array($values)) { |
|
1399 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
1400 | + } |
|
1389 | 1401 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
1390 | 1402 | $finance_rate = PHPExcel_Calculation_Functions::flattenSingleValue($finance_rate); |
1391 | 1403 | $reinvestment_rate = PHPExcel_Calculation_Functions::flattenSingleValue($reinvestment_rate); |
@@ -1810,8 +1822,9 @@ discard block |
||
1810 | 1822 | $rate = ($y1 * $x0 - $y0 * $x1) / ($y1 - $y0); |
1811 | 1823 | $x0 = $x1; |
1812 | 1824 | $x1 = $rate; |
1813 | - if (($nper * abs($pmt)) > ($pv - $fv)) |
|
1814 | - $x1 = abs($x1); |
|
1825 | + if (($nper * abs($pmt)) > ($pv - $fv)) { |
|
1826 | + $x1 = abs($x1); |
|
1827 | + } |
|
1815 | 1828 | |
1816 | 1829 | if (abs($rate) < FINANCIAL_PRECISION) { |
1817 | 1830 | $y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv; |
@@ -2060,11 +2073,15 @@ discard block |
||
2060 | 2073 | |
2061 | 2074 | |
2062 | 2075 | public static function XIRR($values, $dates, $guess = 0.1) { |
2063 | - if ((!is_array($values)) && (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2076 | + if ((!is_array($values)) && (!is_array($dates))) { |
|
2077 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2078 | + } |
|
2064 | 2079 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
2065 | 2080 | $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
2066 | 2081 | $guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess); |
2067 | - if (count($values) != count($dates)) return PHPExcel_Calculation_Functions::NaN(); |
|
2082 | + if (count($values) != count($dates)) { |
|
2083 | + return PHPExcel_Calculation_Functions::NaN(); |
|
2084 | + } |
|
2068 | 2085 | |
2069 | 2086 | // create an initial range, with a root somewhere between 0 and guess |
2070 | 2087 | $x1 = 0.0; |
@@ -2072,14 +2089,18 @@ discard block |
||
2072 | 2089 | $f1 = self::XNPV($x1, $values, $dates); |
2073 | 2090 | $f2 = self::XNPV($x2, $values, $dates); |
2074 | 2091 | for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) { |
2075 | - if (($f1 * $f2) < 0.0) break; |
|
2092 | + if (($f1 * $f2) < 0.0) { |
|
2093 | + break; |
|
2094 | + } |
|
2076 | 2095 | if (abs($f1) < abs($f2)) { |
2077 | 2096 | $f1 = self::XNPV($x1 += 1.6 * ($x1 - $x2), $values, $dates); |
2078 | 2097 | } else { |
2079 | 2098 | $f2 = self::XNPV($x2 += 1.6 * ($x2 - $x1), $values, $dates); |
2080 | 2099 | } |
2081 | 2100 | } |
2082 | - if (($f1 * $f2) > 0.0) return PHPExcel_Calculation_Functions::VALUE(); |
|
2101 | + if (($f1 * $f2) > 0.0) { |
|
2102 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2103 | + } |
|
2083 | 2104 | |
2084 | 2105 | $f = self::XNPV($x1, $values, $dates); |
2085 | 2106 | if ($f < 0.0) { |
@@ -2094,8 +2115,12 @@ discard block |
||
2094 | 2115 | $dx *= 0.5; |
2095 | 2116 | $x_mid = $rtb + $dx; |
2096 | 2117 | $f_mid = self::XNPV($x_mid, $values, $dates); |
2097 | - if ($f_mid <= 0.0) $rtb = $x_mid; |
|
2098 | - if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) return $x_mid; |
|
2118 | + if ($f_mid <= 0.0) { |
|
2119 | + $rtb = $x_mid; |
|
2120 | + } |
|
2121 | + if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) { |
|
2122 | + return $x_mid; |
|
2123 | + } |
|
2099 | 2124 | } |
2100 | 2125 | return PHPExcel_Calculation_Functions::VALUE(); |
2101 | 2126 | } |
@@ -2117,17 +2142,27 @@ discard block |
||
2117 | 2142 | */ |
2118 | 2143 | public static function XNPV($rate, $values, $dates) { |
2119 | 2144 | $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate); |
2120 | - if (!is_numeric($rate)) return PHPExcel_Calculation_Functions::VALUE(); |
|
2121 | - if ((!is_array($values)) || (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE(); |
|
2145 | + if (!is_numeric($rate)) { |
|
2146 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2147 | + } |
|
2148 | + if ((!is_array($values)) || (!is_array($dates))) { |
|
2149 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2150 | + } |
|
2122 | 2151 | $values = PHPExcel_Calculation_Functions::flattenArray($values); |
2123 | 2152 | $dates = PHPExcel_Calculation_Functions::flattenArray($dates); |
2124 | 2153 | $valCount = count($values); |
2125 | - if ($valCount != count($dates)) return PHPExcel_Calculation_Functions::NaN(); |
|
2126 | - if ((min($values) > 0) || (max($values) < 0)) return PHPExcel_Calculation_Functions::VALUE(); |
|
2154 | + if ($valCount != count($dates)) { |
|
2155 | + return PHPExcel_Calculation_Functions::NaN(); |
|
2156 | + } |
|
2157 | + if ((min($values) > 0) || (max($values) < 0)) { |
|
2158 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2159 | + } |
|
2127 | 2160 | |
2128 | 2161 | $xnpv = 0.0; |
2129 | 2162 | for ($i = 0; $i < $valCount; ++$i) { |
2130 | - if (!is_numeric($values[$i])) return PHPExcel_Calculation_Functions::VALUE(); |
|
2163 | + if (!is_numeric($values[$i])) { |
|
2164 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
2165 | + } |
|
2131 | 2166 | $xnpv += $values[$i] / pow(1 + $rate, PHPExcel_Calculation_DateTime::DATEDIF($dates[0],$dates[$i],'d') / 365); |
2132 | 2167 | } |
2133 | 2168 | return (is_finite($xnpv)) ? $xnpv : PHPExcel_Calculation_Functions::VALUE(); |
@@ -409,7 +409,7 @@ |
||
409 | 409 | } elseif ($period <= $nNumOfFullPeriods) { |
410 | 410 | return $fOneRate; |
411 | 411 | } elseif ($period == ($nNumOfFullPeriods + 1)) { |
412 | - return ($fCostDelta - $fOneRate * $nNumOfFullPeriods - $f0Rate); |
|
412 | + return ($fCostDelta - $fOneRate * $nNumOfFullPeriods - $f0Rate); |
|
413 | 413 | } else { |
414 | 414 | return 0.0; |
415 | 415 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * Get Token |
122 | 122 | * |
123 | 123 | * @param int $pId Token id |
124 | - * @return string |
|
124 | + * @return PHPExcel_Calculation_FormulaToken |
|
125 | 125 | * @throws Exception |
126 | 126 | */ |
127 | 127 | public function getToken($pId = 0) { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * Get Token count |
137 | 137 | * |
138 | - * @return string |
|
138 | + * @return integer |
|
139 | 139 | */ |
140 | 140 | public function getTokenCount() { |
141 | 141 | return count($this->_tokens); |
@@ -89,71 +89,71 @@ discard block |
||
89 | 89 | */ |
90 | 90 | private $_tokens = array(); |
91 | 91 | |
92 | - /** |
|
93 | - * Create a new PHPExcel_Calculation_FormulaParser |
|
94 | - * |
|
95 | - * @param string $pFormula Formula to parse |
|
96 | - * @throws Exception |
|
97 | - */ |
|
98 | - public function __construct($pFormula = '') |
|
99 | - { |
|
100 | - // Check parameters |
|
101 | - if (is_null($pFormula)) { |
|
102 | - throw new Exception("Invalid parameter passed: formula"); |
|
103 | - } |
|
104 | - |
|
105 | - // Initialise values |
|
106 | - $this->_formula = trim($pFormula); |
|
107 | - // Parse! |
|
108 | - $this->_parseToTokens(); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get Formula |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public function getFormula() { |
|
117 | - return $this->_formula; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Get Token |
|
122 | - * |
|
123 | - * @param int $pId Token id |
|
124 | - * @return string |
|
125 | - * @throws Exception |
|
126 | - */ |
|
127 | - public function getToken($pId = 0) { |
|
128 | - if (isset($this->_tokens[$pId])) { |
|
129 | - return $this->_tokens[$pId]; |
|
130 | - } else { |
|
131 | - throw new Exception("Token with id $pId does not exist."); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Get Token count |
|
137 | - * |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function getTokenCount() { |
|
141 | - return count($this->_tokens); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Get Tokens |
|
146 | - * |
|
147 | - * @return PHPExcel_Calculation_FormulaToken[] |
|
148 | - */ |
|
149 | - public function getTokens() { |
|
150 | - return $this->_tokens; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Parse to tokens |
|
155 | - */ |
|
156 | - private function _parseToTokens() { |
|
92 | + /** |
|
93 | + * Create a new PHPExcel_Calculation_FormulaParser |
|
94 | + * |
|
95 | + * @param string $pFormula Formula to parse |
|
96 | + * @throws Exception |
|
97 | + */ |
|
98 | + public function __construct($pFormula = '') |
|
99 | + { |
|
100 | + // Check parameters |
|
101 | + if (is_null($pFormula)) { |
|
102 | + throw new Exception("Invalid parameter passed: formula"); |
|
103 | + } |
|
104 | + |
|
105 | + // Initialise values |
|
106 | + $this->_formula = trim($pFormula); |
|
107 | + // Parse! |
|
108 | + $this->_parseToTokens(); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get Formula |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public function getFormula() { |
|
117 | + return $this->_formula; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Get Token |
|
122 | + * |
|
123 | + * @param int $pId Token id |
|
124 | + * @return string |
|
125 | + * @throws Exception |
|
126 | + */ |
|
127 | + public function getToken($pId = 0) { |
|
128 | + if (isset($this->_tokens[$pId])) { |
|
129 | + return $this->_tokens[$pId]; |
|
130 | + } else { |
|
131 | + throw new Exception("Token with id $pId does not exist."); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Get Token count |
|
137 | + * |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function getTokenCount() { |
|
141 | + return count($this->_tokens); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Get Tokens |
|
146 | + * |
|
147 | + * @return PHPExcel_Calculation_FormulaToken[] |
|
148 | + */ |
|
149 | + public function getTokens() { |
|
150 | + return $this->_tokens; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Parse to tokens |
|
155 | + */ |
|
156 | + private function _parseToTokens() { |
|
157 | 157 | // No attempt is made to verify formulas; assumes formulas are derived from Excel, where |
158 | 158 | // they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions. |
159 | 159 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | continue; |
454 | 454 | } |
455 | 455 | |
456 | - // token accumulation |
|
456 | + // token accumulation |
|
457 | 457 | $value .= $this->_formula{$index}; |
458 | 458 | ++$index; |
459 | 459 | } |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | } |
609 | 609 | } |
610 | 610 | |
611 | - $this->_tokens[] = $token; |
|
611 | + $this->_tokens[] = $token; |
|
612 | 612 | } |
613 | - } |
|
613 | + } |
|
614 | 614 | } |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | const COMMA = ','; |
72 | 72 | const ERROR_START = '#'; |
73 | 73 | |
74 | - const OPERATORS_SN = "+-"; |
|
75 | - const OPERATORS_INFIX = "+-*/^&=><"; |
|
76 | - const OPERATORS_POSTFIX = "%"; |
|
74 | + const OPERATORS_SN = "+-"; |
|
75 | + const OPERATORS_INFIX = "+-*/^&=><"; |
|
76 | + const OPERATORS_POSTFIX = "%"; |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Formula |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | if ($formulaLength < 2 || $this->_formula{0} != '=') return; |
163 | 163 | |
164 | 164 | // Helper variables |
165 | - $tokens1 = $tokens2 = $stack = array(); |
|
166 | - $inString = $inPath = $inRange = $inError = false; |
|
167 | - $token = $previousToken = $nextToken = null; |
|
165 | + $tokens1 = $tokens2 = $stack = array(); |
|
166 | + $inString = $inPath = $inRange = $inError = false; |
|
167 | + $token = $previousToken = $nextToken = null; |
|
168 | 168 | |
169 | 169 | $index = 1; |
170 | 170 | $value = ''; |
171 | 171 | |
172 | - $ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"); |
|
173 | - $COMPARATORS_MULTI = array(">=", "<=", "<>"); |
|
172 | + $ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A"); |
|
173 | + $COMPARATORS_MULTI = array(">=", "<=", "<>"); |
|
174 | 174 | |
175 | 175 | while ($index < $formulaLength) { |
176 | 176 | // state-dependent character evaluation (order is important) |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | // standard infix operators |
382 | 382 | if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->_formula{$index}) !== false) { |
383 | 383 | if (strlen($value) > 0) { |
384 | - $tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); |
|
384 | + $tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND); |
|
385 | 385 | $value = ""; |
386 | 386 | } |
387 | 387 | $tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX); |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | continue; |
492 | 492 | } |
493 | 493 | |
494 | - if (! ( |
|
494 | + if ( ! ( |
|
495 | 495 | (($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || |
496 | 496 | (($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) || |
497 | 497 | ($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND) |
498 | - ) ) { |
|
498 | + )) { |
|
499 | 499 | continue; |
500 | 500 | } |
501 | 501 | |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | continue; |
504 | 504 | } |
505 | 505 | |
506 | - if (! ( |
|
506 | + if ( ! ( |
|
507 | 507 | (($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) || |
508 | 508 | (($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) || |
509 | 509 | ($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND) |
510 | - ) ) { |
|
510 | + )) { |
|
511 | 511 | continue; |
512 | 512 | } |
513 | 513 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | } |
587 | 587 | |
588 | 588 | if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) { |
589 | - if (!is_numeric($token->getValue())) { |
|
589 | + if ( ! is_numeric($token->getValue())) { |
|
590 | 590 | if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) { |
591 | 591 | $token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL); |
592 | 592 | } else { |
@@ -159,7 +159,9 @@ |
||
159 | 159 | |
160 | 160 | // Check if the formula has a valid starting = |
161 | 161 | $formulaLength = strlen($this->_formula); |
162 | - if ($formulaLength < 2 || $this->_formula{0} != '=') return; |
|
162 | + if ($formulaLength < 2 || $this->_formula{0} != '=') { |
|
163 | + return; |
|
164 | + } |
|
163 | 165 | |
164 | 166 | // Helper variables |
165 | 167 | $tokens1 = $tokens2 = $stack = array(); |
@@ -97,8 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @access public |
99 | 99 | * @category Logical Functions |
100 | - * @param mixed $arg,... Data values |
|
101 | - * @return boolean The logical AND of the arguments. |
|
100 | + * @return string|boolean The logical AND of the arguments. |
|
102 | 101 | */ |
103 | 102 | public static function LOGICAL_AND() { |
104 | 103 | // Return value |
@@ -152,8 +151,7 @@ discard block |
||
152 | 151 | * |
153 | 152 | * @access public |
154 | 153 | * @category Logical Functions |
155 | - * @param mixed $arg,... Data values |
|
156 | - * @return boolean The logical OR of the arguments. |
|
154 | + * @return string|boolean The logical OR of the arguments. |
|
157 | 155 | */ |
158 | 156 | public static function LOGICAL_OR() { |
159 | 157 | // Return value |
@@ -207,7 +205,7 @@ discard block |
||
207 | 205 | * @access public |
208 | 206 | * @category Logical Functions |
209 | 207 | * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE |
210 | - * @return boolean The boolean inverse of the argument. |
|
208 | + * @return boolean|string The boolean inverse of the argument. |
|
211 | 209 | */ |
212 | 210 | public static function NOT($logical=FALSE) { |
213 | 211 | $logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical); |
@@ -252,8 +250,8 @@ discard block |
||
252 | 250 | * |
253 | 251 | * @access public |
254 | 252 | * @category Logical Functions |
255 | - * @param mixed $condition Condition to evaluate |
|
256 | - * @param mixed $returnIfTrue Value to return when condition is true |
|
253 | + * @param boolean $condition Condition to evaluate |
|
254 | + * @param integer $returnIfTrue Value to return when condition is true |
|
257 | 255 | * @param mixed $returnIfFalse Optional value to return when condition is false |
258 | 256 | * @return mixed The value of returnIfTrue or returnIfFalse determined by condition |
259 | 257 | */ |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // Is it a boolean value? |
112 | 112 | if (is_bool($arg)) { |
113 | 113 | $returnValue = $returnValue && $arg; |
114 | - } elseif ((is_numeric($arg)) && (!is_string($arg))) { |
|
114 | + } elseif ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
115 | 115 | $returnValue = $returnValue && ($arg != 0); |
116 | 116 | } elseif (is_string($arg)) { |
117 | 117 | $arg = strtoupper($arg); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // Is it a boolean value? |
167 | 167 | if (is_bool($arg)) { |
168 | 168 | $returnValue = $returnValue || $arg; |
169 | - } elseif ((is_numeric($arg)) && (!is_string($arg))) { |
|
169 | + } elseif ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
170 | 170 | $returnValue = $returnValue || ($arg != 0); |
171 | 171 | } elseif (is_string($arg)) { |
172 | 172 | $arg = strtoupper($arg); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE |
210 | 210 | * @return boolean The boolean inverse of the argument. |
211 | 211 | */ |
212 | - public static function NOT($logical=FALSE) { |
|
212 | + public static function NOT($logical = FALSE) { |
|
213 | 213 | $logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical); |
214 | 214 | if (is_string($logical)) { |
215 | 215 | $logical = strtoupper($logical); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | - return !$logical; |
|
225 | + return ! $logical; |
|
226 | 226 | } // function NOT() |
227 | 227 | |
228 | 228 | /** |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | * @return mixed The value of returnIfTrue or returnIfFalse determined by condition |
259 | 259 | */ |
260 | 260 | public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) { |
261 | - $condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition); |
|
262 | - $returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue); |
|
263 | - $returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse); |
|
261 | + $condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition); |
|
262 | + $returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue); |
|
263 | + $returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse); |
|
264 | 264 | |
265 | 265 | return ($condition) ? $returnIfTrue : $returnIfFalse; |
266 | 266 | } // function STATEMENT_IF() |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * @return mixed The value of errorpart or testValue determined by error condition |
280 | 280 | */ |
281 | 281 | public static function IFERROR($testValue = '', $errorpart = '') { |
282 | - $testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue); |
|
283 | - $errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart); |
|
282 | + $testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue); |
|
283 | + $errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart); |
|
284 | 284 | |
285 | 285 | return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue); |
286 | 286 | } // function IFERROR() |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param row Row number to use in the cell reference |
58 | 58 | * @param column Column number to use in the cell reference |
59 | - * @param relativity Flag indicating the type of reference to return |
|
59 | + * @param relativity integer indicating the type of reference to return |
|
60 | 60 | * 1 or omitted Absolute |
61 | 61 | * 2 Absolute row; relative column |
62 | 62 | * 3 Relative row; absolute column |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @param cellAddress The reference from which you want to base the offset. Reference must refer to a cell or |
347 | 347 | * range of adjacent cells; otherwise, OFFSET returns the #VALUE! error value. |
348 | - * @param rows The number of rows, up or down, that you want the upper-left cell to refer to. |
|
348 | + * @param rows integer number of rows, up or down, that you want the upper-left cell to refer to. |
|
349 | 349 | * Using 5 as the rows argument specifies that the upper-left cell in the reference is |
350 | 350 | * five rows below reference. Rows can be positive (which means below the starting reference) |
351 | 351 | * or negative (which means above the starting reference). |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @param lookup_value The value that you want to match in lookup_array |
482 | 482 | * @param lookup_array The range of cells being searched |
483 | - * @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered. |
|
483 | + * @param match_type integer number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered. |
|
484 | 484 | * @return integer The relative position of the found item |
485 | 485 | */ |
486 | 486 | public static function MATCH($lookup_value, $lookup_array, $match_type=1) { |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number. |
683 | 683 | * @param lookup_value The value that you want to match in lookup_array |
684 | 684 | * @param lookup_array The range of cells being searched |
685 | - * @param index_number The column number in table_array from which the matching value must be returned. The first column is 1. |
|
685 | + * @param index_number integer column number in table_array from which the matching value must be returned. The first column is 1. |
|
686 | 686 | * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. |
687 | 687 | * @return mixed The value of the found cell |
688 | 688 | */ |
@@ -678,14 +678,14 @@ |
||
678 | 678 | |
679 | 679 | |
680 | 680 | /** |
681 | - * VLOOKUP |
|
682 | - * The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number. |
|
683 | - * @param lookup_value The value that you want to match in lookup_array |
|
684 | - * @param lookup_array The range of cells being searched |
|
685 | - * @param index_number The column number in table_array from which the matching value must be returned. The first column is 1. |
|
686 | - * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. |
|
687 | - * @return mixed The value of the found cell |
|
688 | - */ |
|
681 | + * VLOOKUP |
|
682 | + * The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number. |
|
683 | + * @param lookup_value The value that you want to match in lookup_array |
|
684 | + * @param lookup_array The range of cells being searched |
|
685 | + * @param index_number The column number in table_array from which the matching value must be returned. The first column is 1. |
|
686 | + * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. |
|
687 | + * @return mixed The value of the found cell |
|
688 | + */ |
|
689 | 689 | public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) { |
690 | 690 | $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
691 | 691 | $index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number); |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -67,23 +67,23 @@ discard block |
||
67 | 67 | * @param sheetText Optional Name of worksheet to use |
68 | 68 | * @return string |
69 | 69 | */ |
70 | - public static function CELL_ADDRESS($row, $column, $relativity=1, $referenceStyle=True, $sheetText='') { |
|
71 | - $row = PHPExcel_Calculation_Functions::flattenSingleValue($row); |
|
72 | - $column = PHPExcel_Calculation_Functions::flattenSingleValue($column); |
|
73 | - $relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity); |
|
74 | - $sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText); |
|
70 | + public static function CELL_ADDRESS($row, $column, $relativity = 1, $referenceStyle = True, $sheetText = '') { |
|
71 | + $row = PHPExcel_Calculation_Functions::flattenSingleValue($row); |
|
72 | + $column = PHPExcel_Calculation_Functions::flattenSingleValue($column); |
|
73 | + $relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity); |
|
74 | + $sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText); |
|
75 | 75 | |
76 | 76 | if (($row < 1) || ($column < 1)) { |
77 | 77 | return PHPExcel_Calculation_Functions::VALUE(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | if ($sheetText > '') { |
81 | - if (strpos($sheetText,' ') !== False) { $sheetText = "'".$sheetText."'"; } |
|
82 | - $sheetText .='!'; |
|
81 | + if (strpos($sheetText, ' ') !== False) { $sheetText = "'".$sheetText."'"; } |
|
82 | + $sheetText .= '!'; |
|
83 | 83 | } |
84 | - if ((!is_bool($referenceStyle)) || $referenceStyle) { |
|
84 | + if (( ! is_bool($referenceStyle)) || $referenceStyle) { |
|
85 | 85 | $rowRelative = $columnRelative = '$'; |
86 | - $column = PHPExcel_Cell::stringFromColumnIndex($column-1); |
|
86 | + $column = PHPExcel_Cell::stringFromColumnIndex($column - 1); |
|
87 | 87 | if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; } |
88 | 88 | if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; } |
89 | 89 | return $sheetText.$columnRelative.$column.$rowRelative.$row; |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | * @param cellAddress A reference to a range of cells for which you want the column numbers |
110 | 110 | * @return integer or array of integer |
111 | 111 | */ |
112 | - public static function COLUMN($cellAddress=Null) { |
|
112 | + public static function COLUMN($cellAddress = Null) { |
|
113 | 113 | if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; } |
114 | 114 | |
115 | 115 | if (is_array($cellAddress)) { |
116 | - foreach($cellAddress as $columnKey => $value) { |
|
117 | - $columnKey = preg_replace('/[^a-z]/i','',$columnKey); |
|
116 | + foreach ($cellAddress as $columnKey => $value) { |
|
117 | + $columnKey = preg_replace('/[^a-z]/i', '', $columnKey); |
|
118 | 118 | return (integer) PHPExcel_Cell::columnIndexFromString($columnKey); |
119 | 119 | } |
120 | 120 | } else { |
121 | - if (strpos($cellAddress,'!') !== false) { |
|
122 | - list($sheet,$cellAddress) = explode('!',$cellAddress); |
|
121 | + if (strpos($cellAddress, '!') !== false) { |
|
122 | + list($sheet, $cellAddress) = explode('!', $cellAddress); |
|
123 | 123 | } |
124 | - if (strpos($cellAddress,':') !== false) { |
|
125 | - list($startAddress,$endAddress) = explode(':',$cellAddress); |
|
126 | - $startAddress = preg_replace('/[^a-z]/i','',$startAddress); |
|
127 | - $endAddress = preg_replace('/[^a-z]/i','',$endAddress); |
|
124 | + if (strpos($cellAddress, ':') !== false) { |
|
125 | + list($startAddress, $endAddress) = explode(':', $cellAddress); |
|
126 | + $startAddress = preg_replace('/[^a-z]/i', '', $startAddress); |
|
127 | + $endAddress = preg_replace('/[^a-z]/i', '', $endAddress); |
|
128 | 128 | $returnValue = array(); |
129 | 129 | do { |
130 | 130 | $returnValue[] = (integer) PHPExcel_Cell::columnIndexFromString($startAddress); |
131 | 131 | } while ($startAddress++ != $endAddress); |
132 | 132 | return $returnValue; |
133 | 133 | } else { |
134 | - $cellAddress = preg_replace('/[^a-z]/i','',$cellAddress); |
|
134 | + $cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress); |
|
135 | 135 | return (integer) PHPExcel_Cell::columnIndexFromString($cellAddress); |
136 | 136 | } |
137 | 137 | } |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns |
150 | 150 | * @return integer The number of columns in cellAddress |
151 | 151 | */ |
152 | - public static function COLUMNS($cellAddress=Null) { |
|
152 | + public static function COLUMNS($cellAddress = Null) { |
|
153 | 153 | if (is_null($cellAddress) || $cellAddress === '') { |
154 | 154 | return 1; |
155 | - } elseif (!is_array($cellAddress)) { |
|
155 | + } elseif ( ! is_array($cellAddress)) { |
|
156 | 156 | return PHPExcel_Calculation_Functions::VALUE(); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $x = array_keys($cellAddress); |
160 | 160 | $x = array_shift($x); |
161 | 161 | $isMatrix = (is_numeric($x)); |
162 | - list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); |
|
162 | + list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); |
|
163 | 163 | |
164 | 164 | if ($isMatrix) { |
165 | 165 | return $rows; |
@@ -183,31 +183,31 @@ discard block |
||
183 | 183 | * @param cellAddress A reference to a range of cells for which you want the row numbers |
184 | 184 | * @return integer or array of integer |
185 | 185 | */ |
186 | - public static function ROW($cellAddress=Null) { |
|
186 | + public static function ROW($cellAddress = Null) { |
|
187 | 187 | if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; } |
188 | 188 | |
189 | 189 | if (is_array($cellAddress)) { |
190 | - foreach($cellAddress as $columnKey => $rowValue) { |
|
191 | - foreach($rowValue as $rowKey => $cellValue) { |
|
192 | - return (integer) preg_replace('/[^0-9]/i','',$rowKey); |
|
190 | + foreach ($cellAddress as $columnKey => $rowValue) { |
|
191 | + foreach ($rowValue as $rowKey => $cellValue) { |
|
192 | + return (integer) preg_replace('/[^0-9]/i', '', $rowKey); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } else { |
196 | - if (strpos($cellAddress,'!') !== false) { |
|
197 | - list($sheet,$cellAddress) = explode('!',$cellAddress); |
|
196 | + if (strpos($cellAddress, '!') !== false) { |
|
197 | + list($sheet, $cellAddress) = explode('!', $cellAddress); |
|
198 | 198 | } |
199 | - if (strpos($cellAddress,':') !== false) { |
|
200 | - list($startAddress,$endAddress) = explode(':',$cellAddress); |
|
201 | - $startAddress = preg_replace('/[^0-9]/','',$startAddress); |
|
202 | - $endAddress = preg_replace('/[^0-9]/','',$endAddress); |
|
199 | + if (strpos($cellAddress, ':') !== false) { |
|
200 | + list($startAddress, $endAddress) = explode(':', $cellAddress); |
|
201 | + $startAddress = preg_replace('/[^0-9]/', '', $startAddress); |
|
202 | + $endAddress = preg_replace('/[^0-9]/', '', $endAddress); |
|
203 | 203 | $returnValue = array(); |
204 | 204 | do { |
205 | 205 | $returnValue[][] = (integer) $startAddress; |
206 | 206 | } while ($startAddress++ != $endAddress); |
207 | 207 | return $returnValue; |
208 | 208 | } else { |
209 | - list($cellAddress) = explode(':',$cellAddress); |
|
210 | - return (integer) preg_replace('/[^0-9]/','',$cellAddress); |
|
209 | + list($cellAddress) = explode(':', $cellAddress); |
|
210 | + return (integer) preg_replace('/[^0-9]/', '', $cellAddress); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | } // function ROW() |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows |
225 | 225 | * @return integer The number of rows in cellAddress |
226 | 226 | */ |
227 | - public static function ROWS($cellAddress=Null) { |
|
227 | + public static function ROWS($cellAddress = Null) { |
|
228 | 228 | if (is_null($cellAddress) || $cellAddress === '') { |
229 | 229 | return 1; |
230 | - } elseif (!is_array($cellAddress)) { |
|
230 | + } elseif ( ! is_array($cellAddress)) { |
|
231 | 231 | return PHPExcel_Calculation_Functions::VALUE(); |
232 | 232 | } |
233 | 233 | |
234 | 234 | $i = array_keys($cellAddress); |
235 | 235 | $isMatrix = (is_numeric(array_shift($i))); |
236 | - list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); |
|
236 | + list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); |
|
237 | 237 | |
238 | 238 | if ($isMatrix) { |
239 | 239 | return $columns; |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | $args = func_get_args(); |
260 | 260 | $pCell = array_pop($args); |
261 | 261 | |
262 | - $linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL); |
|
263 | - $displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName); |
|
262 | + $linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL); |
|
263 | + $displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName); |
|
264 | 264 | |
265 | - if ((!is_object($pCell)) || (trim($linkURL) == '')) { |
|
265 | + if (( ! is_object($pCell)) || (trim($linkURL) == '')) { |
|
266 | 266 | return PHPExcel_Calculation_Functions::REF(); |
267 | 267 | } |
268 | 268 | |
@@ -293,27 +293,27 @@ discard block |
||
293 | 293 | * @todo Support for the optional a1 parameter introduced in Excel 2010 |
294 | 294 | * |
295 | 295 | */ |
296 | - public static function INDIRECT($cellAddress=Null, PHPExcel_Cell $pCell = null) { |
|
297 | - $cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress); |
|
296 | + public static function INDIRECT($cellAddress = Null, PHPExcel_Cell $pCell = null) { |
|
297 | + $cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress); |
|
298 | 298 | if (is_null($cellAddress) || $cellAddress === '') { |
299 | 299 | return PHPExcel_Calculation_Functions::REF(); |
300 | 300 | } |
301 | 301 | |
302 | 302 | $cellAddress1 = $cellAddress; |
303 | 303 | $cellAddress2 = NULL; |
304 | - if (strpos($cellAddress,':') !== false) { |
|
305 | - list($cellAddress1,$cellAddress2) = explode(':',$cellAddress); |
|
304 | + if (strpos($cellAddress, ':') !== false) { |
|
305 | + list($cellAddress1, $cellAddress2) = explode(':', $cellAddress); |
|
306 | 306 | } |
307 | 307 | |
308 | - if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) || |
|
309 | - ((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) { |
|
308 | + if (( ! preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) || |
|
309 | + (( ! is_null($cellAddress2)) && ( ! preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) { |
|
310 | 310 | |
311 | - if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) { |
|
311 | + if ( ! preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) { |
|
312 | 312 | return PHPExcel_Calculation_Functions::REF(); |
313 | 313 | } |
314 | 314 | |
315 | - if (strpos($cellAddress,'!') !== false) { |
|
316 | - list($sheetName,$cellAddress) = explode('!',$cellAddress); |
|
315 | + if (strpos($cellAddress, '!') !== false) { |
|
316 | + list($sheetName, $cellAddress) = explode('!', $cellAddress); |
|
317 | 317 | $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName); |
318 | 318 | } else { |
319 | 319 | $pSheet = $pCell->getParent(); |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, False); |
323 | 323 | } |
324 | 324 | |
325 | - if (strpos($cellAddress,'!') !== false) { |
|
326 | - list($sheetName,$cellAddress) = explode('!',$cellAddress); |
|
325 | + if (strpos($cellAddress, '!') !== false) { |
|
326 | + list($sheetName, $cellAddress) = explode('!', $cellAddress); |
|
327 | 327 | $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName); |
328 | 328 | } else { |
329 | 329 | $pSheet = $pCell->getParent(); |
@@ -358,32 +358,32 @@ discard block |
||
358 | 358 | * @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number. |
359 | 359 | * @return string A reference to a cell or range of cells |
360 | 360 | */ |
361 | - public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) { |
|
362 | - $rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows); |
|
361 | + public static function OFFSET($cellAddress = Null, $rows = 0, $columns = 0, $height = null, $width = null) { |
|
362 | + $rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows); |
|
363 | 363 | $columns = PHPExcel_Calculation_Functions::flattenSingleValue($columns); |
364 | 364 | $height = PHPExcel_Calculation_Functions::flattenSingleValue($height); |
365 | - $width = PHPExcel_Calculation_Functions::flattenSingleValue($width); |
|
365 | + $width = PHPExcel_Calculation_Functions::flattenSingleValue($width); |
|
366 | 366 | if ($cellAddress == Null) { |
367 | 367 | return 0; |
368 | 368 | } |
369 | 369 | |
370 | 370 | $args = func_get_args(); |
371 | 371 | $pCell = array_pop($args); |
372 | - if (!is_object($pCell)) { |
|
372 | + if ( ! is_object($pCell)) { |
|
373 | 373 | return PHPExcel_Calculation_Functions::REF(); |
374 | 374 | } |
375 | 375 | |
376 | 376 | $sheetName = null; |
377 | - if (strpos($cellAddress,"!")) { |
|
378 | - list($sheetName,$cellAddress) = explode("!",$cellAddress); |
|
377 | + if (strpos($cellAddress, "!")) { |
|
378 | + list($sheetName, $cellAddress) = explode("!", $cellAddress); |
|
379 | 379 | } |
380 | - if (strpos($cellAddress,":")) { |
|
381 | - list($startCell,$endCell) = explode(":",$cellAddress); |
|
380 | + if (strpos($cellAddress, ":")) { |
|
381 | + list($startCell, $endCell) = explode(":", $cellAddress); |
|
382 | 382 | } else { |
383 | 383 | $startCell = $endCell = $cellAddress; |
384 | 384 | } |
385 | - list($startCellColumn,$startCellRow) = PHPExcel_Cell::coordinateFromString($startCell); |
|
386 | - list($endCellColumn,$endCellRow) = PHPExcel_Cell::coordinateFromString($endCell); |
|
385 | + list($startCellColumn, $startCellRow) = PHPExcel_Cell::coordinateFromString($startCell); |
|
386 | + list($endCellColumn, $endCellRow) = PHPExcel_Cell::coordinateFromString($endCell); |
|
387 | 387 | |
388 | 388 | $startCellRow += $rows; |
389 | 389 | $startCellColumn = PHPExcel_Cell::columnIndexFromString($startCellColumn) - 1; |
@@ -393,14 +393,14 @@ discard block |
||
393 | 393 | return PHPExcel_Calculation_Functions::REF(); |
394 | 394 | } |
395 | 395 | $endCellColumn = PHPExcel_Cell::columnIndexFromString($endCellColumn) - 1; |
396 | - if (($width != null) && (!is_object($width))) { |
|
396 | + if (($width != null) && ( ! is_object($width))) { |
|
397 | 397 | $endCellColumn = $startCellColumn + $width - 1; |
398 | 398 | } else { |
399 | 399 | $endCellColumn += $columns; |
400 | 400 | } |
401 | 401 | $startCellColumn = PHPExcel_Cell::stringFromColumnIndex($startCellColumn); |
402 | 402 | |
403 | - if (($height != null) && (!is_object($height))) { |
|
403 | + if (($height != null) && ( ! is_object($height))) { |
|
404 | 404 | $endCellRow = $startCellRow + $height - 1; |
405 | 405 | } else { |
406 | 406 | $endCellRow += $rows; |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | $chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs)); |
450 | 450 | $entryCount = count($chooseArgs) - 1; |
451 | 451 | |
452 | - if(is_array($chosenEntry)) { |
|
452 | + if (is_array($chosenEntry)) { |
|
453 | 453 | $chosenEntry = array_shift($chosenEntry); |
454 | 454 | } |
455 | - if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) { |
|
455 | + if ((is_numeric($chosenEntry)) && ( ! is_bool($chosenEntry))) { |
|
456 | 456 | --$chosenEntry; |
457 | 457 | } else { |
458 | 458 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -483,15 +483,15 @@ discard block |
||
483 | 483 | * @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered. |
484 | 484 | * @return integer The relative position of the found item |
485 | 485 | */ |
486 | - public static function MATCH($lookup_value, $lookup_array, $match_type=1) { |
|
486 | + public static function MATCH($lookup_value, $lookup_array, $match_type = 1) { |
|
487 | 487 | $lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array); |
488 | 488 | $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
489 | - $match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type); |
|
489 | + $match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type); |
|
490 | 490 | // MATCH is not case sensitive |
491 | 491 | $lookup_value = strtolower($lookup_value); |
492 | 492 | |
493 | 493 | // lookup_value type has to be number, text, or logical values |
494 | - if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) { |
|
494 | + if (( ! is_numeric($lookup_value)) && ( ! is_string($lookup_value)) && ( ! is_bool($lookup_value))) { |
|
495 | 495 | return PHPExcel_Calculation_Functions::NA(); |
496 | 496 | } |
497 | 497 | |
@@ -507,10 +507,10 @@ discard block |
||
507 | 507 | } |
508 | 508 | |
509 | 509 | // lookup_array should contain only number, text, or logical values, or empty (null) cells |
510 | - foreach($lookup_array as $i => $lookupArrayValue) { |
|
510 | + foreach ($lookup_array as $i => $lookupArrayValue) { |
|
511 | 511 | // check the type of the value |
512 | - if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) && |
|
513 | - (!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) { |
|
512 | + if (( ! is_numeric($lookupArrayValue)) && ( ! is_string($lookupArrayValue)) && |
|
513 | + ( ! is_bool($lookupArrayValue)) && ( ! is_null($lookupArrayValue))) { |
|
514 | 514 | return PHPExcel_Calculation_Functions::NA(); |
515 | 515 | } |
516 | 516 | // convert strings to lowercase for case-insensitive testing |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | $lookup_array[$i] = strtolower($lookupArrayValue); |
519 | 519 | } |
520 | 520 | if ((is_null($lookupArrayValue)) && (($match_type == 1) || ($match_type == -1))) { |
521 | - $lookup_array = array_slice($lookup_array,0,$i-1); |
|
521 | + $lookup_array = array_slice($lookup_array, 0, $i - 1); |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | if ($match_type == 1) { |
527 | 527 | asort($lookup_array); |
528 | 528 | $keySet = array_keys($lookup_array); |
529 | - } elseif($match_type == -1) { |
|
529 | + } elseif ($match_type == -1) { |
|
530 | 530 | arsort($lookup_array); |
531 | 531 | $keySet = array_keys($lookup_array); |
532 | 532 | } |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | // loop on the cells |
538 | 538 | // var_dump($lookup_array); |
539 | 539 | // echo '<br />'; |
540 | - foreach($lookup_array as $i => $lookupArrayValue) { |
|
540 | + foreach ($lookup_array as $i => $lookupArrayValue) { |
|
541 | 541 | if (($match_type == 0) && ($lookupArrayValue == $lookup_value)) { |
542 | 542 | // exact match |
543 | 543 | return ++$i; |
@@ -548,15 +548,15 @@ discard block |
||
548 | 548 | // echo 'Keyset = '; |
549 | 549 | // var_dump($keySet); |
550 | 550 | // echo '<br />'; |
551 | - $i = array_search($i,$keySet); |
|
551 | + $i = array_search($i, $keySet); |
|
552 | 552 | // echo '$i='.$i.'<br />'; |
553 | 553 | // if match_type is -1 <=> find the smallest value that is greater than or equal to lookup_value |
554 | - if ($i < 1){ |
|
554 | + if ($i < 1) { |
|
555 | 555 | // 1st cell was allready smaller than the lookup_value |
556 | 556 | break; |
557 | 557 | } else { |
558 | 558 | // the previous cell was the match |
559 | - return $keySet[$i-1]+1; |
|
559 | + return $keySet[$i - 1] + 1; |
|
560 | 560 | } |
561 | 561 | } elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) { |
562 | 562 | // echo '$i = '.$i.' => '; |
@@ -565,15 +565,15 @@ discard block |
||
565 | 565 | // echo 'Keyset = '; |
566 | 566 | // var_dump($keySet); |
567 | 567 | // echo '<br />'; |
568 | - $i = array_search($i,$keySet); |
|
568 | + $i = array_search($i, $keySet); |
|
569 | 569 | // echo '$i='.$i.'<br />'; |
570 | 570 | // if match_type is 1 <=> find the largest value that is less than or equal to lookup_value |
571 | - if ($i < 1){ |
|
571 | + if ($i < 1) { |
|
572 | 572 | // 1st cell was allready bigger than the lookup_value |
573 | 573 | break; |
574 | 574 | } else { |
575 | 575 | // the previous cell was the match |
576 | - return $keySet[$i-1]+1; |
|
576 | + return $keySet[$i - 1] + 1; |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | } |
@@ -596,13 +596,13 @@ discard block |
||
596 | 596 | * @param column_num The column in array from which to return a value. If column_num is omitted, row_num is required. |
597 | 597 | * @return mixed the value of a specified cell or array of cells |
598 | 598 | */ |
599 | - public static function INDEX($arrayValues,$rowNum = 0,$columnNum = 0) { |
|
599 | + public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0) { |
|
600 | 600 | |
601 | 601 | if (($rowNum < 0) || ($columnNum < 0)) { |
602 | 602 | return PHPExcel_Calculation_Functions::VALUE(); |
603 | 603 | } |
604 | 604 | |
605 | - if (!is_array($arrayValues)) { |
|
605 | + if ( ! is_array($arrayValues)) { |
|
606 | 606 | return PHPExcel_Calculation_Functions::REF(); |
607 | 607 | } |
608 | 608 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } |
618 | 618 | $rowNum = $rowKeys[--$rowNum]; |
619 | 619 | $returnArray = array(); |
620 | - foreach($arrayValues as $arrayColumn) { |
|
620 | + foreach ($arrayValues as $arrayColumn) { |
|
621 | 621 | if (is_array($arrayColumn)) { |
622 | 622 | if (isset($arrayColumn[$rowNum])) { |
623 | 623 | $returnArray[] = $arrayColumn[$rowNum]; |
@@ -652,12 +652,12 @@ discard block |
||
652 | 652 | */ |
653 | 653 | public static function TRANSPOSE($matrixData) { |
654 | 654 | $returnMatrix = array(); |
655 | - if (!is_array($matrixData)) { $matrixData = array(array($matrixData)); } |
|
655 | + if ( ! is_array($matrixData)) { $matrixData = array(array($matrixData)); } |
|
656 | 656 | |
657 | 657 | $column = 0; |
658 | - foreach($matrixData as $matrixRow) { |
|
658 | + foreach ($matrixData as $matrixRow) { |
|
659 | 659 | $row = 0; |
660 | - foreach($matrixRow as $matrixCell) { |
|
660 | + foreach ($matrixRow as $matrixCell) { |
|
661 | 661 | $returnMatrix[$row][$column] = $matrixCell; |
662 | 662 | ++$row; |
663 | 663 | } |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | } // function TRANSPOSE() |
668 | 668 | |
669 | 669 | |
670 | - private static function _vlookupSort($a,$b) { |
|
670 | + private static function _vlookupSort($a, $b) { |
|
671 | 671 | $f = array_keys($a); |
672 | 672 | $firstColumn = array_shift($f); |
673 | 673 | if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) { |
@@ -686,10 +686,10 @@ discard block |
||
686 | 686 | * @param not_exact_match Determines if you are looking for an exact match based on lookup_value. |
687 | 687 | * @return mixed The value of the found cell |
688 | 688 | */ |
689 | - public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) { |
|
689 | + public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true) { |
|
690 | 690 | $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
691 | 691 | $index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number); |
692 | - $not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match); |
|
692 | + $not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match); |
|
693 | 693 | |
694 | 694 | // index_number must be greater than or equal to 1 |
695 | 695 | if ($index_number < 1) { |
@@ -697,12 +697,12 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | // index_number must be less than or equal to the number of columns in lookup_array |
700 | - if ((!is_array($lookup_array)) || (empty($lookup_array))) { |
|
700 | + if (( ! is_array($lookup_array)) || (empty($lookup_array))) { |
|
701 | 701 | return PHPExcel_Calculation_Functions::REF(); |
702 | 702 | } else { |
703 | 703 | $f = array_keys($lookup_array); |
704 | 704 | $firstRow = array_pop($f); |
705 | - if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { |
|
705 | + if (( ! is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { |
|
706 | 706 | return PHPExcel_Calculation_Functions::REF(); |
707 | 707 | } else { |
708 | 708 | $columnKeys = array_keys($lookup_array[$firstRow]); |
@@ -711,12 +711,12 @@ discard block |
||
711 | 711 | } |
712 | 712 | } |
713 | 713 | |
714 | - if (!$not_exact_match) { |
|
715 | - uasort($lookup_array,array('self','_vlookupSort')); |
|
714 | + if ( ! $not_exact_match) { |
|
715 | + uasort($lookup_array, array('self', '_vlookupSort')); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | $rowNumber = $rowValue = False; |
719 | - foreach($lookup_array as $rowKey => $rowData) { |
|
719 | + foreach ($lookup_array as $rowKey => $rowData) { |
|
720 | 720 | if (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)) { |
721 | 721 | break; |
722 | 722 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | } |
726 | 726 | |
727 | 727 | if ($rowNumber !== false) { |
728 | - if ((!$not_exact_match) && ($rowValue != $lookup_value)) { |
|
728 | + if (( ! $not_exact_match) && ($rowValue != $lookup_value)) { |
|
729 | 729 | // if an exact match is required, we have what we need to return an appropriate response |
730 | 730 | return PHPExcel_Calculation_Functions::NA(); |
731 | 731 | } else { |
@@ -746,10 +746,10 @@ discard block |
||
746 | 746 | * @param result_vector The column from which the matching value must be returned |
747 | 747 | * @return mixed The value of the found cell |
748 | 748 | */ |
749 | - public static function LOOKUP($lookup_value, $lookup_vector, $result_vector=null) { |
|
750 | - $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
|
749 | + public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null) { |
|
750 | + $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); |
|
751 | 751 | |
752 | - if (!is_array($lookup_vector)) { |
|
752 | + if ( ! is_array($lookup_vector)) { |
|
753 | 753 | return PHPExcel_Calculation_Functions::NA(); |
754 | 754 | } |
755 | 755 | $lookupRows = count($lookup_vector); |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | $lookup_vector = array_shift($lookup_vector); |
783 | 783 | } |
784 | 784 | if ($lookupColumns != 2) { |
785 | - foreach($lookup_vector as &$value) { |
|
785 | + foreach ($lookup_vector as &$value) { |
|
786 | 786 | if (is_array($value)) { |
787 | 787 | $k = array_keys($value); |
788 | 788 | $key1 = $key2 = array_shift($k); |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | unset($value); |
803 | 803 | } |
804 | 804 | |
805 | - return self::VLOOKUP($lookup_value,$lookup_vector,2); |
|
805 | + return self::VLOOKUP($lookup_value, $lookup_vector, 2); |
|
806 | 806 | } // function LOOKUP() |
807 | 807 | |
808 | 808 | } // class PHPExcel_Calculation_LookupRef |
@@ -70,6 +70,10 @@ discard block |
||
70 | 70 | } // function _factors() |
71 | 71 | |
72 | 72 | |
73 | + /** |
|
74 | + * @param integer $num |
|
75 | + * @param integer $n |
|
76 | + */ |
|
73 | 77 | private static function _romanCut($num, $n) { |
74 | 78 | return ($num - ($num % $n ) ) / $n; |
75 | 79 | } // function _romanCut() |
@@ -423,8 +427,7 @@ discard block |
||
423 | 427 | * |
424 | 428 | * @access public |
425 | 429 | * @category Mathematical and Trigonometric Functions |
426 | - * @param float $value The positive real number for which you want the logarithm |
|
427 | - * @param float $base The base of the logarithm. If base is omitted, it is assumed to be 10. |
|
430 | + * @param integer $base The base of the logarithm. If base is omitted, it is assumed to be 10. |
|
428 | 431 | * @return float |
429 | 432 | */ |
430 | 433 | public static function LOG_BASE($number = NULL, $base=10) { |
@@ -681,8 +684,8 @@ discard block |
||
681 | 684 | * |
682 | 685 | * Computes x raised to the power y. |
683 | 686 | * |
684 | - * @param float $x |
|
685 | - * @param float $y |
|
687 | + * @param integer $x |
|
688 | + * @param integer $y |
|
686 | 689 | * @return float |
687 | 690 | */ |
688 | 691 | public static function POWER($x = 0, $y = 2) { |
@@ -712,7 +715,6 @@ discard block |
||
712 | 715 | * |
713 | 716 | * @access public |
714 | 717 | * @category Mathematical and Trigonometric Functions |
715 | - * @param mixed $arg,... Data values |
|
716 | 718 | * @return float |
717 | 719 | */ |
718 | 720 | public static function PRODUCT() { |
@@ -750,8 +752,7 @@ discard block |
||
750 | 752 | * |
751 | 753 | * @access public |
752 | 754 | * @category Mathematical and Trigonometric Functions |
753 | - * @param mixed $arg,... Data values |
|
754 | - * @return float |
|
755 | + * @return integer |
|
755 | 756 | */ |
756 | 757 | public static function QUOTIENT() { |
757 | 758 | // Return value |
@@ -881,9 +882,6 @@ discard block |
||
881 | 882 | * |
882 | 883 | * Returns the sum of a power series |
883 | 884 | * |
884 | - * @param float $x Input value to the power series |
|
885 | - * @param float $n Initial power to which you want to raise $x |
|
886 | - * @param float $m Step by which to increase $n for each term in the series |
|
887 | 885 | * @param array of mixed Data Series |
888 | 886 | * @return float |
889 | 887 | */ |
@@ -1028,7 +1026,6 @@ discard block |
||
1028 | 1026 | * |
1029 | 1027 | * @access public |
1030 | 1028 | * @category Mathematical and Trigonometric Functions |
1031 | - * @param mixed $arg,... Data values |
|
1032 | 1029 | * @return float |
1033 | 1030 | */ |
1034 | 1031 | public static function SUM() { |
@@ -1058,9 +1055,8 @@ discard block |
||
1058 | 1055 | * |
1059 | 1056 | * @access public |
1060 | 1057 | * @category Mathematical and Trigonometric Functions |
1061 | - * @param mixed $arg,... Data values |
|
1062 | 1058 | * @param string $condition The criteria that defines which cells will be summed. |
1063 | - * @return float |
|
1059 | + * @return integer |
|
1064 | 1060 | */ |
1065 | 1061 | public static function SUMIF($aArgs,$condition,$sumArgs = array()) { |
1066 | 1062 | // Return value |
@@ -1095,7 +1091,6 @@ discard block |
||
1095 | 1091 | * |
1096 | 1092 | * @access public |
1097 | 1093 | * @category Mathematical and Trigonometric Functions |
1098 | - * @param mixed $arg,... Data values |
|
1099 | 1094 | * @return float |
1100 | 1095 | */ |
1101 | 1096 | public static function SUMPRODUCT() { |
@@ -1139,7 +1134,6 @@ discard block |
||
1139 | 1134 | * |
1140 | 1135 | * @access public |
1141 | 1136 | * @category Mathematical and Trigonometric Functions |
1142 | - * @param mixed $arg,... Data values |
|
1143 | 1137 | * @return float |
1144 | 1138 | */ |
1145 | 1139 | public static function SUMSQ() { |
@@ -1162,7 +1156,6 @@ discard block |
||
1162 | 1156 | /** |
1163 | 1157 | * SUMX2MY2 |
1164 | 1158 | * |
1165 | - * @param mixed $value Value to check |
|
1166 | 1159 | * @return float |
1167 | 1160 | */ |
1168 | 1161 | public static function SUMX2MY2($matrixData1,$matrixData2) { |
@@ -1191,7 +1184,6 @@ discard block |
||
1191 | 1184 | /** |
1192 | 1185 | * SUMX2PY2 |
1193 | 1186 | * |
1194 | - * @param mixed $value Value to check |
|
1195 | 1187 | * @return float |
1196 | 1188 | */ |
1197 | 1189 | public static function SUMX2PY2($matrixData1,$matrixData2) { |
@@ -1220,7 +1212,6 @@ discard block |
||
1220 | 1212 | /** |
1221 | 1213 | * SUMXMY2 |
1222 | 1214 | * |
1223 | - * @param mixed $value Value to check |
|
1224 | 1215 | * @return float |
1225 | 1216 | */ |
1226 | 1217 | public static function SUMXMY2($matrixData1,$matrixData2) { |
@@ -1251,7 +1242,7 @@ discard block |
||
1251 | 1242 | * |
1252 | 1243 | * Truncates value to the number of fractional digits by number_digits. |
1253 | 1244 | * |
1254 | - * @param float $value |
|
1245 | + * @param integer $value |
|
1255 | 1246 | * @param int $digits |
1256 | 1247 | * @return float Truncated value |
1257 | 1248 | */ |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param p require p>0 |
146 | 146 | * @param q require q>0 |
147 | - * @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow |
|
147 | + * @return double if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow |
|
148 | 148 | * @author Jaco van Kooten |
149 | 149 | */ |
150 | 150 | private static function _logBeta($p, $q) { |
@@ -165,6 +165,8 @@ discard block |
||
165 | 165 | * Evaluates of continued fraction part of incomplete beta function. |
166 | 166 | * Based on an idea from Numerical Recipes (W.H. Press et al, 1992). |
167 | 167 | * @author Jaco van Kooten |
168 | + * @param double $p |
|
169 | + * @param double $q |
|
168 | 170 | */ |
169 | 171 | private static function _betaFraction($x, $p, $q) { |
170 | 172 | $c = 1.0; |
@@ -694,7 +696,6 @@ discard block |
||
694 | 696 | * |
695 | 697 | * @access public |
696 | 698 | * @category Statistical Functions |
697 | - * @param mixed $arg,... Data values |
|
698 | 699 | * @return float |
699 | 700 | */ |
700 | 701 | public static function AVEDEV() { |
@@ -742,7 +743,6 @@ discard block |
||
742 | 743 | * |
743 | 744 | * @access public |
744 | 745 | * @category Statistical Functions |
745 | - * @param mixed $arg,... Data values |
|
746 | 746 | * @return float |
747 | 747 | */ |
748 | 748 | public static function AVERAGE() { |
@@ -784,7 +784,6 @@ discard block |
||
784 | 784 | * |
785 | 785 | * @access public |
786 | 786 | * @category Statistical Functions |
787 | - * @param mixed $arg,... Data values |
|
788 | 787 | * @return float |
789 | 788 | */ |
790 | 789 | public static function AVERAGEA() { |
@@ -832,7 +831,6 @@ discard block |
||
832 | 831 | * |
833 | 832 | * @access public |
834 | 833 | * @category Mathematical and Trigonometric Functions |
835 | - * @param mixed $arg,... Data values |
|
836 | 834 | * @param string $condition The criteria that defines which cells will be checked. |
837 | 835 | * @return float |
838 | 836 | */ |
@@ -876,7 +874,6 @@ discard block |
||
876 | 874 | * @param float $value Value at which you want to evaluate the distribution |
877 | 875 | * @param float $alpha Parameter to the distribution |
878 | 876 | * @param float $beta Parameter to the distribution |
879 | - * @param boolean $cumulative |
|
880 | 877 | * @return float |
881 | 878 | * |
882 | 879 | */ |
@@ -912,7 +909,6 @@ discard block |
||
912 | 909 | * @param float $probability Probability at which you want to evaluate the distribution |
913 | 910 | * @param float $alpha Parameter to the distribution |
914 | 911 | * @param float $beta Parameter to the distribution |
915 | - * @param boolean $cumulative |
|
916 | 912 | * @return float |
917 | 913 | * |
918 | 914 | */ |
@@ -1156,7 +1152,6 @@ discard block |
||
1156 | 1152 | * |
1157 | 1153 | * @access public |
1158 | 1154 | * @category Statistical Functions |
1159 | - * @param mixed $arg,... Data values |
|
1160 | 1155 | * @return int |
1161 | 1156 | */ |
1162 | 1157 | public static function COUNT() { |
@@ -1191,7 +1186,6 @@ discard block |
||
1191 | 1186 | * |
1192 | 1187 | * @access public |
1193 | 1188 | * @category Statistical Functions |
1194 | - * @param mixed $arg,... Data values |
|
1195 | 1189 | * @return int |
1196 | 1190 | */ |
1197 | 1191 | public static function COUNTA() { |
@@ -1222,7 +1216,6 @@ discard block |
||
1222 | 1216 | * |
1223 | 1217 | * @access public |
1224 | 1218 | * @category Statistical Functions |
1225 | - * @param mixed $arg,... Data values |
|
1226 | 1219 | * @return int |
1227 | 1220 | */ |
1228 | 1221 | public static function COUNTBLANK() { |
@@ -1253,7 +1246,6 @@ discard block |
||
1253 | 1246 | * |
1254 | 1247 | * @access public |
1255 | 1248 | * @category Statistical Functions |
1256 | - * @param mixed $arg,... Data values |
|
1257 | 1249 | * @param string $condition The criteria that defines which cells will be counted. |
1258 | 1250 | * @return int |
1259 | 1251 | */ |
@@ -1425,7 +1417,6 @@ discard block |
||
1425 | 1417 | * |
1426 | 1418 | * @access public |
1427 | 1419 | * @category Statistical Functions |
1428 | - * @param mixed $arg,... Data values |
|
1429 | 1420 | * @return float |
1430 | 1421 | */ |
1431 | 1422 | public static function DEVSQ() { |
@@ -1700,7 +1691,6 @@ discard block |
||
1700 | 1691 | * |
1701 | 1692 | * @access public |
1702 | 1693 | * @category Statistical Functions |
1703 | - * @param mixed $arg,... Data values |
|
1704 | 1694 | * @return float |
1705 | 1695 | */ |
1706 | 1696 | public static function GEOMEAN() { |
@@ -1759,7 +1749,6 @@ discard block |
||
1759 | 1749 | * |
1760 | 1750 | * @access public |
1761 | 1751 | * @category Statistical Functions |
1762 | - * @param mixed $arg,... Data values |
|
1763 | 1752 | * @return float |
1764 | 1753 | */ |
1765 | 1754 | public static function HARMEAN() { |
@@ -1911,8 +1900,6 @@ discard block |
||
1911 | 1900 | * |
1912 | 1901 | * @access public |
1913 | 1902 | * @category Statistical Functions |
1914 | - * @param mixed $arg,... Data values |
|
1915 | - * @param int $entry Position (ordered from the largest) in the array or range of data to return |
|
1916 | 1903 | * @return float |
1917 | 1904 | * |
1918 | 1905 | */ |
@@ -2059,7 +2046,6 @@ discard block |
||
2059 | 2046 | * |
2060 | 2047 | * Returns the inverse of the normal cumulative distribution |
2061 | 2048 | * |
2062 | - * @param float $value |
|
2063 | 2049 | * @return float |
2064 | 2050 | * |
2065 | 2051 | * @todo Try implementing P J Acklam's refinement algorithm for greater |
@@ -2116,7 +2102,6 @@ discard block |
||
2116 | 2102 | * |
2117 | 2103 | * @access public |
2118 | 2104 | * @category Statistical Functions |
2119 | - * @param mixed $arg,... Data values |
|
2120 | 2105 | * @return float |
2121 | 2106 | */ |
2122 | 2107 | public static function MAX() { |
@@ -2152,7 +2137,6 @@ discard block |
||
2152 | 2137 | * |
2153 | 2138 | * @access public |
2154 | 2139 | * @category Statistical Functions |
2155 | - * @param mixed $arg,... Data values |
|
2156 | 2140 | * @return float |
2157 | 2141 | */ |
2158 | 2142 | public static function MAXA() { |
@@ -2193,7 +2177,6 @@ discard block |
||
2193 | 2177 | * |
2194 | 2178 | * @access public |
2195 | 2179 | * @category Mathematical and Trigonometric Functions |
2196 | - * @param mixed $arg,... Data values |
|
2197 | 2180 | * @param string $condition The criteria that defines which cells will be checked. |
2198 | 2181 | * @return float |
2199 | 2182 | */ |
@@ -2233,7 +2216,6 @@ discard block |
||
2233 | 2216 | * |
2234 | 2217 | * @access public |
2235 | 2218 | * @category Statistical Functions |
2236 | - * @param mixed $arg,... Data values |
|
2237 | 2219 | * @return float |
2238 | 2220 | */ |
2239 | 2221 | public static function MEDIAN() { |
@@ -2278,7 +2260,6 @@ discard block |
||
2278 | 2260 | * |
2279 | 2261 | * @access public |
2280 | 2262 | * @category Statistical Functions |
2281 | - * @param mixed $arg,... Data values |
|
2282 | 2263 | * @return float |
2283 | 2264 | */ |
2284 | 2265 | public static function MIN() { |
@@ -2314,7 +2295,6 @@ discard block |
||
2314 | 2295 | * |
2315 | 2296 | * @access public |
2316 | 2297 | * @category Statistical Functions |
2317 | - * @param mixed $arg,... Data values |
|
2318 | 2298 | * @return float |
2319 | 2299 | */ |
2320 | 2300 | public static function MINA() { |
@@ -2355,7 +2335,6 @@ discard block |
||
2355 | 2335 | * |
2356 | 2336 | * @access public |
2357 | 2337 | * @category Mathematical and Trigonometric Functions |
2358 | - * @param mixed $arg,... Data values |
|
2359 | 2338 | * @param string $condition The criteria that defines which cells will be checked. |
2360 | 2339 | * @return float |
2361 | 2340 | */ |
@@ -2429,7 +2408,6 @@ discard block |
||
2429 | 2408 | * |
2430 | 2409 | * @access public |
2431 | 2410 | * @category Statistical Functions |
2432 | - * @param mixed $arg,... Data values |
|
2433 | 2411 | * @return float |
2434 | 2412 | */ |
2435 | 2413 | public static function MODE() { |
@@ -2534,9 +2512,9 @@ discard block |
||
2534 | 2512 | * |
2535 | 2513 | * Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation. |
2536 | 2514 | * |
2537 | - * @param float $value |
|
2538 | 2515 | * @param float $mean Mean Value |
2539 | 2516 | * @param float $stdDev Standard Deviation |
2517 | + * @param double $probability |
|
2540 | 2518 | * @return float |
2541 | 2519 | * |
2542 | 2520 | */ |
@@ -2598,8 +2576,6 @@ discard block |
||
2598 | 2576 | * |
2599 | 2577 | * @access public |
2600 | 2578 | * @category Statistical Functions |
2601 | - * @param mixed $arg,... Data values |
|
2602 | - * @param float $entry Percentile value in the range 0..1, inclusive. |
|
2603 | 2579 | * @return float |
2604 | 2580 | */ |
2605 | 2581 | public static function PERCENTILE() { |
@@ -2759,8 +2735,6 @@ discard block |
||
2759 | 2735 | * |
2760 | 2736 | * @access public |
2761 | 2737 | * @category Statistical Functions |
2762 | - * @param mixed $arg,... Data values |
|
2763 | - * @param int $entry Quartile value in the range 1..3, inclusive. |
|
2764 | 2738 | * @return float |
2765 | 2739 | */ |
2766 | 2740 | public static function QUARTILE() { |
@@ -2918,8 +2892,6 @@ discard block |
||
2918 | 2892 | * |
2919 | 2893 | * @access public |
2920 | 2894 | * @category Statistical Functions |
2921 | - * @param mixed $arg,... Data values |
|
2922 | - * @param int $entry Position (ordered from the smallest) in the array or range of data to return |
|
2923 | 2895 | * @return float |
2924 | 2896 | */ |
2925 | 2897 | public static function SMALL() { |
@@ -2984,7 +2956,6 @@ discard block |
||
2984 | 2956 | * |
2985 | 2957 | * @access public |
2986 | 2958 | * @category Statistical Functions |
2987 | - * @param mixed $arg,... Data values |
|
2988 | 2959 | * @return float |
2989 | 2960 | */ |
2990 | 2961 | public static function STDEV() { |
@@ -3031,7 +3002,6 @@ discard block |
||
3031 | 3002 | * |
3032 | 3003 | * @access public |
3033 | 3004 | * @category Statistical Functions |
3034 | - * @param mixed $arg,... Data values |
|
3035 | 3005 | * @return float |
3036 | 3006 | */ |
3037 | 3007 | public static function STDEVA() { |
@@ -3083,7 +3053,6 @@ discard block |
||
3083 | 3053 | * |
3084 | 3054 | * @access public |
3085 | 3055 | * @category Statistical Functions |
3086 | - * @param mixed $arg,... Data values |
|
3087 | 3056 | * @return float |
3088 | 3057 | */ |
3089 | 3058 | public static function STDEVP() { |
@@ -3130,7 +3099,6 @@ discard block |
||
3130 | 3099 | * |
3131 | 3100 | * @access public |
3132 | 3101 | * @category Statistical Functions |
3133 | - * @param mixed $arg,... Data values |
|
3134 | 3102 | * @return float |
3135 | 3103 | */ |
3136 | 3104 | public static function STDEVPA() { |
@@ -3358,8 +3326,6 @@ discard block |
||
3358 | 3326 | * |
3359 | 3327 | * @access public |
3360 | 3328 | * @category Statistical Functions |
3361 | - * @param mixed $arg,... Data values |
|
3362 | - * @param float $discard Percentage to discard |
|
3363 | 3329 | * @return float |
3364 | 3330 | */ |
3365 | 3331 | public static function TRIMMEAN() { |
@@ -3401,7 +3367,6 @@ discard block |
||
3401 | 3367 | * |
3402 | 3368 | * @access public |
3403 | 3369 | * @category Statistical Functions |
3404 | - * @param mixed $arg,... Data values |
|
3405 | 3370 | * @return float |
3406 | 3371 | */ |
3407 | 3372 | public static function VARFunc() { |
@@ -3443,7 +3408,6 @@ discard block |
||
3443 | 3408 | * |
3444 | 3409 | * @access public |
3445 | 3410 | * @category Statistical Functions |
3446 | - * @param mixed $arg,... Data values |
|
3447 | 3411 | * @return float |
3448 | 3412 | */ |
3449 | 3413 | public static function VARA() { |
@@ -3496,7 +3460,6 @@ discard block |
||
3496 | 3460 | * |
3497 | 3461 | * @access public |
3498 | 3462 | * @category Statistical Functions |
3499 | - * @param mixed $arg,... Data values |
|
3500 | 3463 | * @return float |
3501 | 3464 | */ |
3502 | 3465 | public static function VARP() { |
@@ -3538,7 +3501,6 @@ discard block |
||
3538 | 3501 | * |
3539 | 3502 | * @access public |
3540 | 3503 | * @category Statistical Functions |
3541 | - * @param mixed $arg,... Data values |
|
3542 | 3504 | * @return float |
3543 | 3505 | */ |
3544 | 3506 | public static function VARPA() { |
@@ -3621,10 +3583,6 @@ discard block |
||
3621 | 3583 | * Returns the Weibull distribution. Use this distribution in reliability |
3622 | 3584 | * analysis, such as calculating a device's mean time to failure. |
3623 | 3585 | * |
3624 | - * @param float $value |
|
3625 | - * @param float $alpha Alpha Parameter |
|
3626 | - * @param float $beta Beta Parameter |
|
3627 | - * @param boolean $cumulative |
|
3628 | 3586 | * @return float |
3629 | 3587 | * |
3630 | 3588 | */ |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | -require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/trendClass.php'; |
|
39 | +require_once PHPEXCEL_ROOT.'PHPExcel/Shared/trend/trendClass.php'; |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** LOG_GAMMA_X_MAX_VALUE */ |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | class PHPExcel_Calculation_Statistical { |
63 | 63 | |
64 | 64 | |
65 | - private static function _checkTrendArrays(&$array1,&$array2) { |
|
66 | - if (!is_array($array1)) { $array1 = array($array1); } |
|
67 | - if (!is_array($array2)) { $array2 = array($array2); } |
|
65 | + private static function _checkTrendArrays(&$array1, &$array2) { |
|
66 | + if ( ! is_array($array1)) { $array1 = array($array1); } |
|
67 | + if ( ! is_array($array2)) { $array2 = array($array2); } |
|
68 | 68 | |
69 | 69 | $array1 = PHPExcel_Calculation_Functions::flattenArray($array1); |
70 | 70 | $array2 = PHPExcel_Calculation_Functions::flattenArray($array2); |
71 | - foreach($array1 as $key => $value) { |
|
71 | + foreach ($array1 as $key => $value) { |
|
72 | 72 | if ((is_bool($value)) || (is_string($value)) || (is_null($value))) { |
73 | 73 | unset($array1[$key]); |
74 | 74 | unset($array2[$key]); |
75 | 75 | } |
76 | 76 | } |
77 | - foreach($array2 as $key => $value) { |
|
77 | + foreach ($array2 as $key => $value) { |
|
78 | 78 | if ((is_bool($value)) || (is_string($value)) || (is_null($value))) { |
79 | 79 | unset($array1[$key]); |
80 | 80 | unset($array2[$key]); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // Function cache for _logBeta function |
138 | 138 | private static $_logBetaCache_p = 0.0; |
139 | 139 | private static $_logBetaCache_q = 0.0; |
140 | - private static $_logBetaCache_result = 0.0; |
|
140 | + private static $_logBetaCache_result = 0.0; |
|
141 | 141 | |
142 | 142 | /** |
143 | 143 | * The natural logarithm of the beta function. |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | } |
178 | 178 | $h = 1.0 / $h; |
179 | 179 | $frac = $h; |
180 | - $m = 1; |
|
180 | + $m = 1; |
|
181 | 181 | $delta = 0.0; |
182 | - while ($m <= MAX_ITERATIONS && abs($delta-1.0) > PRECISION ) { |
|
182 | + while ($m <= MAX_ITERATIONS && abs($delta - 1.0) > PRECISION) { |
|
183 | 183 | $m2 = 2 * $m; |
184 | 184 | // even index for d |
185 | - $d = $m * ($q - $m) * $x / ( ($p_minus + $m2) * ($p + $m2)); |
|
185 | + $d = $m * ($q - $m) * $x / (($p_minus + $m2) * ($p + $m2)); |
|
186 | 186 | $h = 1.0 + $d * $h; |
187 | 187 | if (abs($h) < XMININ) { |
188 | 188 | $h = XMININ; |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | */ |
257 | 257 | |
258 | 258 | // Function cache for logGamma |
259 | - private static $_logGammaCache_result = 0.0; |
|
260 | - private static $_logGammaCache_x = 0.0; |
|
259 | + private static $_logGammaCache_result = 0.0; |
|
260 | + private static $_logGammaCache_x = 0.0; |
|
261 | 261 | |
262 | 262 | private static function _logGamma($x) { |
263 | 263 | // Log Gamma related constants |
@@ -265,57 +265,57 @@ discard block |
||
265 | 265 | static $lg_d2 = 0.4227843350984671393993777; |
266 | 266 | static $lg_d4 = 1.791759469228055000094023; |
267 | 267 | |
268 | - static $lg_p1 = array( 4.945235359296727046734888, |
|
268 | + static $lg_p1 = array(4.945235359296727046734888, |
|
269 | 269 | 201.8112620856775083915565, |
270 | 270 | 2290.838373831346393026739, |
271 | 271 | 11319.67205903380828685045, |
272 | 272 | 28557.24635671635335736389, |
273 | 273 | 38484.96228443793359990269, |
274 | 274 | 26377.48787624195437963534, |
275 | - 7225.813979700288197698961 ); |
|
276 | - static $lg_p2 = array( 4.974607845568932035012064, |
|
275 | + 7225.813979700288197698961); |
|
276 | + static $lg_p2 = array(4.974607845568932035012064, |
|
277 | 277 | 542.4138599891070494101986, |
278 | 278 | 15506.93864978364947665077, |
279 | 279 | 184793.2904445632425417223, |
280 | 280 | 1088204.76946882876749847, |
281 | 281 | 3338152.967987029735917223, |
282 | 282 | 5106661.678927352456275255, |
283 | - 3074109.054850539556250927 ); |
|
284 | - static $lg_p4 = array( 14745.02166059939948905062, |
|
283 | + 3074109.054850539556250927); |
|
284 | + static $lg_p4 = array(14745.02166059939948905062, |
|
285 | 285 | 2426813.369486704502836312, |
286 | 286 | 121475557.4045093227939592, |
287 | 287 | 2663432449.630976949898078, |
288 | 288 | 29403789566.34553899906876, |
289 | 289 | 170266573776.5398868392998, |
290 | 290 | 492612579337.743088758812, |
291 | - 560625185622.3951465078242 ); |
|
291 | + 560625185622.3951465078242); |
|
292 | 292 | |
293 | - static $lg_q1 = array( 67.48212550303777196073036, |
|
293 | + static $lg_q1 = array(67.48212550303777196073036, |
|
294 | 294 | 1113.332393857199323513008, |
295 | 295 | 7738.757056935398733233834, |
296 | 296 | 27639.87074403340708898585, |
297 | 297 | 54993.10206226157329794414, |
298 | 298 | 61611.22180066002127833352, |
299 | 299 | 36351.27591501940507276287, |
300 | - 8785.536302431013170870835 ); |
|
301 | - static $lg_q2 = array( 183.0328399370592604055942, |
|
300 | + 8785.536302431013170870835); |
|
301 | + static $lg_q2 = array(183.0328399370592604055942, |
|
302 | 302 | 7765.049321445005871323047, |
303 | 303 | 133190.3827966074194402448, |
304 | 304 | 1136705.821321969608938755, |
305 | 305 | 5267964.117437946917577538, |
306 | 306 | 13467014.54311101692290052, |
307 | 307 | 17827365.30353274213975932, |
308 | - 9533095.591844353613395747 ); |
|
309 | - static $lg_q4 = array( 2690.530175870899333379843, |
|
308 | + 9533095.591844353613395747); |
|
309 | + static $lg_q4 = array(2690.530175870899333379843, |
|
310 | 310 | 639388.5654300092398984238, |
311 | 311 | 41355999.30241388052042842, |
312 | 312 | 1120872109.61614794137657, |
313 | 313 | 14886137286.78813811542398, |
314 | 314 | 101680358627.2438228077304, |
315 | 315 | 341747634550.7377132798597, |
316 | - 446315818741.9713286462081 ); |
|
316 | + 446315818741.9713286462081); |
|
317 | 317 | |
318 | - static $lg_c = array( -0.001910444077728, |
|
318 | + static $lg_c = array( -0.001910444077728, |
|
319 | 319 | 8.4171387781295e-4, |
320 | 320 | -5.952379913043012e-4, |
321 | 321 | 7.93650793500350248e-4, |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | // Rough estimate of the fourth root of logGamma_xBig |
327 | 327 | static $lg_frtbig = 2.25e76; |
328 | - static $pnt68 = 0.6796875; |
|
328 | + static $pnt68 = 0.6796875; |
|
329 | 329 | |
330 | 330 | |
331 | 331 | if ($x == self::$_logGammaCache_x) { |
@@ -422,17 +422,17 @@ discard block |
||
422 | 422 | // |
423 | 423 | // Private implementation of the incomplete Gamma function |
424 | 424 | // |
425 | - private static function _incompleteGamma($a,$x) { |
|
425 | + private static function _incompleteGamma($a, $x) { |
|
426 | 426 | static $max = 32; |
427 | 427 | $summer = 0; |
428 | - for ($n=0; $n<=$max; ++$n) { |
|
428 | + for ($n = 0; $n <= $max; ++$n) { |
|
429 | 429 | $divisor = $a; |
430 | - for ($i=1; $i<=$n; ++$i) { |
|
430 | + for ($i = 1; $i <= $n; ++$i) { |
|
431 | 431 | $divisor *= ($a + $i); |
432 | 432 | } |
433 | - $summer += (pow($x,$n) / $divisor); |
|
433 | + $summer += (pow($x, $n) / $divisor); |
|
434 | 434 | } |
435 | - return pow($x,$a) * exp(0-$x) * $summer; |
|
435 | + return pow($x, $a) * exp(0 - $x) * $summer; |
|
436 | 436 | } // function _incompleteGamma() |
437 | 437 | |
438 | 438 | |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | if ($data == 0.0) return 0; |
444 | 444 | |
445 | 445 | static $p0 = 1.000000000190015; |
446 | - static $p = array ( 1 => 76.18009172947146, |
|
446 | + static $p = array(1 => 76.18009172947146, |
|
447 | 447 | 2 => -86.50532032941677, |
448 | 448 | 3 => 24.01409824083091, |
449 | 449 | 4 => -1.231739572450155, |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $tmp -= ($x + 0.5) * log($tmp); |
457 | 457 | |
458 | 458 | $summer = $p0; |
459 | - for ($j=1;$j<=6;++$j) { |
|
459 | + for ($j = 1; $j <= 6; ++$j) { |
|
460 | 460 | $summer += ($p[$j] / ++$y); |
461 | 461 | } |
462 | 462 | return exp(0 - $tmp + log(SQRT2PI * $summer / $x)); |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | // Input paramater is $p - probability - where 0 < p < 1. |
486 | 486 | |
487 | 487 | // Coefficients in rational approximations |
488 | - static $a = array( 1 => -3.969683028665376e+01, |
|
488 | + static $a = array(1 => -3.969683028665376e+01, |
|
489 | 489 | 2 => 2.209460984245205e+02, |
490 | 490 | 3 => -2.759285104469687e+02, |
491 | 491 | 4 => 1.383577518672690e+02, |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | 6 => 2.506628277459239e+00 |
494 | 494 | ); |
495 | 495 | |
496 | - static $b = array( 1 => -5.447609879822406e+01, |
|
496 | + static $b = array(1 => -5.447609879822406e+01, |
|
497 | 497 | 2 => 1.615858368580409e+02, |
498 | 498 | 3 => -1.556989798598866e+02, |
499 | 499 | 4 => 6.680131188771972e+01, |
500 | 500 | 5 => -1.328068155288572e+01 |
501 | 501 | ); |
502 | 502 | |
503 | - static $c = array( 1 => -7.784894002430293e-03, |
|
503 | + static $c = array(1 => -7.784894002430293e-03, |
|
504 | 504 | 2 => -3.223964580411365e-01, |
505 | 505 | 3 => -2.400758277161838e+00, |
506 | 506 | 4 => -2.549732539343734e+00, |
@@ -508,15 +508,15 @@ discard block |
||
508 | 508 | 6 => 2.938163982698783e+00 |
509 | 509 | ); |
510 | 510 | |
511 | - static $d = array( 1 => 7.784695709041462e-03, |
|
511 | + static $d = array(1 => 7.784695709041462e-03, |
|
512 | 512 | 2 => 3.224671290700398e-01, |
513 | 513 | 3 => 2.445134137142996e+00, |
514 | 514 | 4 => 3.754408661907416e+00 |
515 | 515 | ); |
516 | 516 | |
517 | 517 | // Define lower and upper region break-points. |
518 | - $p_low = 0.02425; //Use lower region approx. below this |
|
519 | - $p_high = 1 - $p_low; //Use upper region approx. above this |
|
518 | + $p_low = 0.02425; //Use lower region approx. below this |
|
519 | + $p_high = 1 - $p_low; //Use upper region approx. above this |
|
520 | 520 | |
521 | 521 | if (0 < $p && $p < $p_low) { |
522 | 522 | // Rational approximation for lower region. |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | } else { |
663 | 663 | $R = 1 - $p; |
664 | 664 | } |
665 | - $R = pow(-log($R),2); |
|
665 | + $R = pow(-log($R), 2); |
|
666 | 666 | |
667 | 667 | // computation for p not close to 0, 0.5 or 1. |
668 | 668 | If ($R <= $split2) { |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | $aCount = 0; |
709 | 709 | foreach ($aArgs as $k => $arg) { |
710 | 710 | if ((is_bool($arg)) && |
711 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
711 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
712 | 712 | $arg = (integer) $arg; |
713 | 713 | } |
714 | 714 | // Is it a numeric value? |
715 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
715 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
716 | 716 | if (is_null($returnValue)) { |
717 | 717 | $returnValue = abs($arg - $aMean); |
718 | 718 | } else { |
@@ -751,11 +751,11 @@ discard block |
||
751 | 751 | // Loop through arguments |
752 | 752 | foreach (PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()) as $k => $arg) { |
753 | 753 | if ((is_bool($arg)) && |
754 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
754 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
755 | 755 | $arg = (integer) $arg; |
756 | 756 | } |
757 | 757 | // Is it a numeric value? |
758 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
758 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
759 | 759 | if (is_null($returnValue)) { |
760 | 760 | $returnValue = $arg; |
761 | 761 | } else { |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | // Loop through arguments |
796 | 796 | foreach (PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()) as $k => $arg) { |
797 | 797 | if ((is_bool($arg)) && |
798 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
798 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
799 | 799 | } else { |
800 | 800 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) { |
801 | 801 | if (is_bool($arg)) { |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | * @param string $condition The criteria that defines which cells will be checked. |
837 | 837 | * @return float |
838 | 838 | */ |
839 | - public static function AVERAGEIF($aArgs,$condition,$averageArgs = array()) { |
|
839 | + public static function AVERAGEIF($aArgs, $condition, $averageArgs = array()) { |
|
840 | 840 | // Return value |
841 | 841 | $returnValue = 0; |
842 | 842 | |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | // Loop through arguments |
850 | 850 | $aCount = 0; |
851 | 851 | foreach ($aArgs as $key => $arg) { |
852 | - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
852 | + if ( ! is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
853 | 853 | $testCondition = '='.$arg.$condition; |
854 | 854 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
855 | 855 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | * @return float |
881 | 881 | * |
882 | 882 | */ |
883 | - public static function BETADIST($value,$alpha,$beta,$rMin=0,$rMax=1) { |
|
883 | + public static function BETADIST($value, $alpha, $beta, $rMin = 0, $rMax = 1) { |
|
884 | 884 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
885 | 885 | $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
886 | 886 | $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | } |
899 | 899 | $value -= $rMin; |
900 | 900 | $value /= ($rMax - $rMin); |
901 | - return self::_incompleteBeta($value,$alpha,$beta); |
|
901 | + return self::_incompleteBeta($value, $alpha, $beta); |
|
902 | 902 | } |
903 | 903 | return PHPExcel_Calculation_Functions::VALUE(); |
904 | 904 | } // function BETADIST() |
@@ -916,9 +916,9 @@ discard block |
||
916 | 916 | * @return float |
917 | 917 | * |
918 | 918 | */ |
919 | - public static function BETAINV($probability,$alpha,$beta,$rMin=0,$rMax=1) { |
|
920 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
921 | - $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
919 | + public static function BETAINV($probability, $alpha, $beta, $rMin = 0, $rMax = 1) { |
|
920 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
921 | + $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
922 | 922 | $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
923 | 923 | $rMin = PHPExcel_Calculation_Functions::flattenSingleValue($rMin); |
924 | 924 | $rMax = PHPExcel_Calculation_Functions::flattenSingleValue($rMax); |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | if ($i == MAX_ITERATIONS) { |
951 | 951 | return PHPExcel_Calculation_Functions::NA(); |
952 | 952 | } |
953 | - return round($rMin + $guess * ($rMax - $rMin),12); |
|
953 | + return round($rMin + $guess * ($rMax - $rMin), 12); |
|
954 | 954 | } |
955 | 955 | return PHPExcel_Calculation_Functions::VALUE(); |
956 | 956 | } // function BETAINV() |
@@ -975,9 +975,9 @@ discard block |
||
975 | 975 | * |
976 | 976 | */ |
977 | 977 | public static function BINOMDIST($value, $trials, $probability, $cumulative) { |
978 | - $value = floor(PHPExcel_Calculation_Functions::flattenSingleValue($value)); |
|
979 | - $trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials)); |
|
980 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
978 | + $value = floor(PHPExcel_Calculation_Functions::flattenSingleValue($value)); |
|
979 | + $trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials)); |
|
980 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
981 | 981 | |
982 | 982 | if ((is_numeric($value)) && (is_numeric($trials)) && (is_numeric($probability))) { |
983 | 983 | if (($value < 0) || ($value > $trials)) { |
@@ -990,11 +990,11 @@ discard block |
||
990 | 990 | if ($cumulative) { |
991 | 991 | $summer = 0; |
992 | 992 | for ($i = 0; $i <= $value; ++$i) { |
993 | - $summer += PHPExcel_Calculation_MathTrig::COMBIN($trials,$i) * pow($probability,$i) * pow(1 - $probability,$trials - $i); |
|
993 | + $summer += PHPExcel_Calculation_MathTrig::COMBIN($trials, $i) * pow($probability, $i) * pow(1 - $probability, $trials - $i); |
|
994 | 994 | } |
995 | 995 | return $summer; |
996 | 996 | } else { |
997 | - return PHPExcel_Calculation_MathTrig::COMBIN($trials,$value) * pow($probability,$value) * pow(1 - $probability,$trials - $value) ; |
|
997 | + return PHPExcel_Calculation_MathTrig::COMBIN($trials, $value) * pow($probability, $value) * pow(1 - $probability, $trials - $value); |
|
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | } |
@@ -1012,8 +1012,8 @@ discard block |
||
1012 | 1012 | * @return float |
1013 | 1013 | */ |
1014 | 1014 | public static function CHIDIST($value, $degrees) { |
1015 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1016 | - $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
1015 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1016 | + $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
1017 | 1017 | |
1018 | 1018 | if ((is_numeric($value)) && (is_numeric($degrees))) { |
1019 | 1019 | if ($degrees < 1) { |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | } |
1026 | 1026 | return PHPExcel_Calculation_Functions::NaN(); |
1027 | 1027 | } |
1028 | - return 1 - (self::_incompleteGamma($degrees/2,$value/2) / self::_gamma($degrees/2)); |
|
1028 | + return 1 - (self::_incompleteGamma($degrees / 2, $value / 2) / self::_gamma($degrees / 2)); |
|
1029 | 1029 | } |
1030 | 1030 | return PHPExcel_Calculation_Functions::VALUE(); |
1031 | 1031 | } // function CHIDIST() |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | * @return float |
1042 | 1042 | */ |
1043 | 1043 | public static function CHIINV($probability, $degrees) { |
1044 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1045 | - $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
1044 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1045 | + $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
1046 | 1046 | |
1047 | 1047 | if ((is_numeric($probability)) && (is_numeric($degrees))) { |
1048 | 1048 | |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | $xHi = 0; |
1051 | 1051 | |
1052 | 1052 | $x = $xNew = 1; |
1053 | - $dx = 1; |
|
1053 | + $dx = 1; |
|
1054 | 1054 | $i = 0; |
1055 | 1055 | |
1056 | 1056 | while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | if ($i == MAX_ITERATIONS) { |
1082 | 1082 | return PHPExcel_Calculation_Functions::NA(); |
1083 | 1083 | } |
1084 | - return round($x,12); |
|
1084 | + return round($x, 12); |
|
1085 | 1085 | } |
1086 | 1086 | return PHPExcel_Calculation_Functions::VALUE(); |
1087 | 1087 | } // function CHIINV() |
@@ -1098,10 +1098,10 @@ discard block |
||
1098 | 1098 | * @return float |
1099 | 1099 | * |
1100 | 1100 | */ |
1101 | - public static function CONFIDENCE($alpha,$stdDev,$size) { |
|
1102 | - $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1103 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
1104 | - $size = floor(PHPExcel_Calculation_Functions::flattenSingleValue($size)); |
|
1101 | + public static function CONFIDENCE($alpha, $stdDev, $size) { |
|
1102 | + $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1103 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
1104 | + $size = floor(PHPExcel_Calculation_Functions::flattenSingleValue($size)); |
|
1105 | 1105 | |
1106 | 1106 | if ((is_numeric($alpha)) && (is_numeric($stdDev)) && (is_numeric($size))) { |
1107 | 1107 | if (($alpha <= 0) || ($alpha >= 1)) { |
@@ -1125,11 +1125,11 @@ discard block |
||
1125 | 1125 | * @param array of mixed Data Series X |
1126 | 1126 | * @return float |
1127 | 1127 | */ |
1128 | - public static function CORREL($yValues,$xValues=null) { |
|
1129 | - if ((is_null($xValues)) || (!is_array($yValues)) || (!is_array($xValues))) { |
|
1128 | + public static function CORREL($yValues, $xValues = null) { |
|
1129 | + if ((is_null($xValues)) || ( ! is_array($yValues)) || ( ! is_array($xValues))) { |
|
1130 | 1130 | return PHPExcel_Calculation_Functions::VALUE(); |
1131 | 1131 | } |
1132 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1132 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1133 | 1133 | return PHPExcel_Calculation_Functions::VALUE(); |
1134 | 1134 | } |
1135 | 1135 | $yValueCount = count($yValues); |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | return PHPExcel_Calculation_Functions::DIV0(); |
1142 | 1142 | } |
1143 | 1143 | |
1144 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
1144 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
1145 | 1145 | return $bestFitLinear->getCorrelation(); |
1146 | 1146 | } // function CORREL() |
1147 | 1147 | |
@@ -1167,11 +1167,11 @@ discard block |
||
1167 | 1167 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
1168 | 1168 | foreach ($aArgs as $k => $arg) { |
1169 | 1169 | if ((is_bool($arg)) && |
1170 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1170 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1171 | 1171 | $arg = (integer) $arg; |
1172 | 1172 | } |
1173 | 1173 | // Is it a numeric value? |
1174 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1174 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1175 | 1175 | ++$returnValue; |
1176 | 1176 | } |
1177 | 1177 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | * @param string $condition The criteria that defines which cells will be counted. |
1258 | 1258 | * @return int |
1259 | 1259 | */ |
1260 | - public static function COUNTIF($aArgs,$condition) { |
|
1260 | + public static function COUNTIF($aArgs, $condition) { |
|
1261 | 1261 | // Return value |
1262 | 1262 | $returnValue = 0; |
1263 | 1263 | |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); |
1266 | 1266 | // Loop through arguments |
1267 | 1267 | foreach ($aArgs as $arg) { |
1268 | - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
1268 | + if ( ! is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
1269 | 1269 | $testCondition = '='.$arg.$condition; |
1270 | 1270 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
1271 | 1271 | // Is it a value within our criteria |
@@ -1287,8 +1287,8 @@ discard block |
||
1287 | 1287 | * @param array of mixed Data Series X |
1288 | 1288 | * @return float |
1289 | 1289 | */ |
1290 | - public static function COVAR($yValues,$xValues) { |
|
1291 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1290 | + public static function COVAR($yValues, $xValues) { |
|
1291 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1292 | 1292 | return PHPExcel_Calculation_Functions::VALUE(); |
1293 | 1293 | } |
1294 | 1294 | $yValueCount = count($yValues); |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | return PHPExcel_Calculation_Functions::DIV0(); |
1301 | 1301 | } |
1302 | 1302 | |
1303 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
1303 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
1304 | 1304 | return $bestFitLinear->getCovariance(); |
1305 | 1305 | } // function COVAR() |
1306 | 1306 | |
@@ -1325,9 +1325,9 @@ discard block |
||
1325 | 1325 | * |
1326 | 1326 | */ |
1327 | 1327 | public static function CRITBINOM($trials, $probability, $alpha) { |
1328 | - $trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials)); |
|
1329 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1330 | - $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1328 | + $trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials)); |
|
1329 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1330 | + $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1331 | 1331 | |
1332 | 1332 | if ((is_numeric($trials)) && (is_numeric($probability)) && (is_numeric($alpha))) { |
1333 | 1333 | if ($trials < 0) { |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | $t = sqrt(log(1 / ($alpha * $alpha))); |
1344 | 1344 | $trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t)); |
1345 | 1345 | } else { |
1346 | - $t = sqrt(log(1 / pow(1 - $alpha,2))); |
|
1346 | + $t = sqrt(log(1 / pow(1 - $alpha, 2))); |
|
1347 | 1347 | $trialsApprox = $t - (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t); |
1348 | 1348 | } |
1349 | 1349 | $Guess = floor($trials * $probability + $trialsApprox * sqrt($trials * $probability * (1 - $probability))); |
@@ -1364,7 +1364,7 @@ discard block |
||
1364 | 1364 | $PreviousValue = 1; |
1365 | 1365 | $Done = False; |
1366 | 1366 | $k = $m + 1; |
1367 | - while ((!$Done) && ($k <= $trials)) { |
|
1367 | + while (( ! $Done) && ($k <= $trials)) { |
|
1368 | 1368 | $CurrentValue = $PreviousValue * ($trials - $k + 1) * $probability / ($k * (1 - $probability)); |
1369 | 1369 | $TotalUnscaledProbability += $CurrentValue; |
1370 | 1370 | if ($k == $Guess) { $UnscaledPGuess += $CurrentValue; } |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | $PreviousValue = 1; |
1378 | 1378 | $Done = False; |
1379 | 1379 | $k = $m - 1; |
1380 | - while ((!$Done) && ($k >= 0)) { |
|
1380 | + while (( ! $Done) && ($k >= 0)) { |
|
1381 | 1381 | $CurrentValue = $PreviousValue * $k + 1 * (1 - $probability) / (($trials - $k) * $probability); |
1382 | 1382 | $TotalUnscaledProbability += $CurrentValue; |
1383 | 1383 | if ($k == $Guess) { $UnscaledPGuess += $CurrentValue; } |
@@ -1440,14 +1440,14 @@ discard block |
||
1440 | 1440 | foreach ($aArgs as $k => $arg) { |
1441 | 1441 | // Is it a numeric value? |
1442 | 1442 | if ((is_bool($arg)) && |
1443 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1443 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
1444 | 1444 | $arg = (integer) $arg; |
1445 | 1445 | } |
1446 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1446 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1447 | 1447 | if (is_null($returnValue)) { |
1448 | - $returnValue = pow(($arg - $aMean),2); |
|
1448 | + $returnValue = pow(($arg - $aMean), 2); |
|
1449 | 1449 | } else { |
1450 | - $returnValue += pow(($arg - $aMean),2); |
|
1450 | + $returnValue += pow(($arg - $aMean), 2); |
|
1451 | 1451 | } |
1452 | 1452 | ++$aCount; |
1453 | 1453 | } |
@@ -1477,9 +1477,9 @@ discard block |
||
1477 | 1477 | * @return float |
1478 | 1478 | */ |
1479 | 1479 | public static function EXPONDIST($value, $lambda, $cumulative) { |
1480 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1481 | - $lambda = PHPExcel_Calculation_Functions::flattenSingleValue($lambda); |
|
1482 | - $cumulative = PHPExcel_Calculation_Functions::flattenSingleValue($cumulative); |
|
1480 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1481 | + $lambda = PHPExcel_Calculation_Functions::flattenSingleValue($lambda); |
|
1482 | + $cumulative = PHPExcel_Calculation_Functions::flattenSingleValue($cumulative); |
|
1483 | 1483 | |
1484 | 1484 | if ((is_numeric($value)) && (is_numeric($lambda))) { |
1485 | 1485 | if (($value < 0) || ($lambda < 0)) { |
@@ -1487,9 +1487,9 @@ discard block |
||
1487 | 1487 | } |
1488 | 1488 | if ((is_numeric($cumulative)) || (is_bool($cumulative))) { |
1489 | 1489 | if ($cumulative) { |
1490 | - return 1 - exp(0-$value*$lambda); |
|
1490 | + return 1 - exp(0 - $value * $lambda); |
|
1491 | 1491 | } else { |
1492 | - return $lambda * exp(0-$value*$lambda); |
|
1492 | + return $lambda * exp(0 - $value * $lambda); |
|
1493 | 1493 | } |
1494 | 1494 | } |
1495 | 1495 | } |
@@ -1508,13 +1508,13 @@ discard block |
||
1508 | 1508 | * @return float |
1509 | 1509 | */ |
1510 | 1510 | public static function FISHER($value) { |
1511 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1511 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1512 | 1512 | |
1513 | 1513 | if (is_numeric($value)) { |
1514 | 1514 | if (($value <= -1) || ($value >= 1)) { |
1515 | 1515 | return PHPExcel_Calculation_Functions::NaN(); |
1516 | 1516 | } |
1517 | - return 0.5 * log((1+$value)/(1-$value)); |
|
1517 | + return 0.5 * log((1 + $value) / (1 - $value)); |
|
1518 | 1518 | } |
1519 | 1519 | return PHPExcel_Calculation_Functions::VALUE(); |
1520 | 1520 | } // function FISHER() |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | * @return float |
1532 | 1532 | */ |
1533 | 1533 | public static function FISHERINV($value) { |
1534 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1534 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1535 | 1535 | |
1536 | 1536 | if (is_numeric($value)) { |
1537 | 1537 | return (exp(2 * $value) - 1) / (exp(2 * $value) + 1); |
@@ -1550,13 +1550,13 @@ discard block |
||
1550 | 1550 | * @param array of mixed Data Series X |
1551 | 1551 | * @return float |
1552 | 1552 | */ |
1553 | - public static function FORECAST($xValue,$yValues,$xValues) { |
|
1554 | - $xValue = PHPExcel_Calculation_Functions::flattenSingleValue($xValue); |
|
1555 | - if (!is_numeric($xValue)) { |
|
1553 | + public static function FORECAST($xValue, $yValues, $xValues) { |
|
1554 | + $xValue = PHPExcel_Calculation_Functions::flattenSingleValue($xValue); |
|
1555 | + if ( ! is_numeric($xValue)) { |
|
1556 | 1556 | return PHPExcel_Calculation_Functions::VALUE(); |
1557 | 1557 | } |
1558 | 1558 | |
1559 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1559 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1560 | 1560 | return PHPExcel_Calculation_Functions::VALUE(); |
1561 | 1561 | } |
1562 | 1562 | $yValueCount = count($yValues); |
@@ -1568,7 +1568,7 @@ discard block |
||
1568 | 1568 | return PHPExcel_Calculation_Functions::DIV0(); |
1569 | 1569 | } |
1570 | 1570 | |
1571 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
1571 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
1572 | 1572 | return $bestFitLinear->getValueOfYForX($xValue); |
1573 | 1573 | } // function FORECAST() |
1574 | 1574 | |
@@ -1585,8 +1585,8 @@ discard block |
||
1585 | 1585 | * @return float |
1586 | 1586 | * |
1587 | 1587 | */ |
1588 | - public static function GAMMADIST($value,$a,$b,$cumulative) { |
|
1589 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1588 | + public static function GAMMADIST($value, $a, $b, $cumulative) { |
|
1589 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1590 | 1590 | $a = PHPExcel_Calculation_Functions::flattenSingleValue($a); |
1591 | 1591 | $b = PHPExcel_Calculation_Functions::flattenSingleValue($b); |
1592 | 1592 | |
@@ -1596,9 +1596,9 @@ discard block |
||
1596 | 1596 | } |
1597 | 1597 | if ((is_numeric($cumulative)) || (is_bool($cumulative))) { |
1598 | 1598 | if ($cumulative) { |
1599 | - return self::_incompleteGamma($a,$value / $b) / self::_gamma($a); |
|
1599 | + return self::_incompleteGamma($a, $value / $b) / self::_gamma($a); |
|
1600 | 1600 | } else { |
1601 | - return (1 / (pow($b,$a) * self::_gamma($a))) * pow($value,$a-1) * exp(0-($value / $b)); |
|
1601 | + return (1 / (pow($b, $a) * self::_gamma($a))) * pow($value, $a - 1) * exp(0 - ($value / $b)); |
|
1602 | 1602 | } |
1603 | 1603 | } |
1604 | 1604 | } |
@@ -1617,10 +1617,10 @@ discard block |
||
1617 | 1617 | * @return float |
1618 | 1618 | * |
1619 | 1619 | */ |
1620 | - public static function GAMMAINV($probability,$alpha,$beta) { |
|
1621 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1622 | - $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1623 | - $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
|
1620 | + public static function GAMMAINV($probability, $alpha, $beta) { |
|
1621 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
1622 | + $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
|
1623 | + $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
|
1624 | 1624 | |
1625 | 1625 | if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta))) { |
1626 | 1626 | if (($alpha <= 0) || ($beta <= 0) || ($probability < 0) || ($probability > 1)) { |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | |
1633 | 1633 | $x = $xNew = 1; |
1634 | 1634 | $error = $pdf = 0; |
1635 | - $dx = 1024; |
|
1635 | + $dx = 1024; |
|
1636 | 1636 | $i = 0; |
1637 | 1637 | |
1638 | 1638 | while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { |
@@ -1676,7 +1676,7 @@ discard block |
||
1676 | 1676 | * @return float |
1677 | 1677 | */ |
1678 | 1678 | public static function GAMMALN($value) { |
1679 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1679 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
1680 | 1680 | |
1681 | 1681 | if (is_numeric($value)) { |
1682 | 1682 | if ($value <= 0) { |
@@ -1708,7 +1708,7 @@ discard block |
||
1708 | 1708 | |
1709 | 1709 | $aMean = PHPExcel_Calculation_MathTrig::PRODUCT($aArgs); |
1710 | 1710 | if (is_numeric($aMean) && ($aMean > 0)) { |
1711 | - $aCount = self::COUNT($aArgs) ; |
|
1711 | + $aCount = self::COUNT($aArgs); |
|
1712 | 1712 | if (self::MIN($aArgs) > 0) { |
1713 | 1713 | return pow($aMean, (1 / $aCount)); |
1714 | 1714 | } |
@@ -1728,19 +1728,19 @@ discard block |
||
1728 | 1728 | * @param boolean A logical value specifying whether to force the intersect to equal 0. |
1729 | 1729 | * @return array of float |
1730 | 1730 | */ |
1731 | - public static function GROWTH($yValues,$xValues=array(),$newValues=array(),$const=True) { |
|
1731 | + public static function GROWTH($yValues, $xValues = array(), $newValues = array(), $const = True) { |
|
1732 | 1732 | $yValues = PHPExcel_Calculation_Functions::flattenArray($yValues); |
1733 | 1733 | $xValues = PHPExcel_Calculation_Functions::flattenArray($xValues); |
1734 | 1734 | $newValues = PHPExcel_Calculation_Functions::flattenArray($newValues); |
1735 | - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
1735 | + $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
1736 | 1736 | |
1737 | - $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const); |
|
1737 | + $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL, $yValues, $xValues, $const); |
|
1738 | 1738 | if (empty($newValues)) { |
1739 | 1739 | $newValues = $bestFitExponential->getXValues(); |
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | $returnArray = array(); |
1743 | - foreach($newValues as $xValue) { |
|
1743 | + foreach ($newValues as $xValue) { |
|
1744 | 1744 | $returnArray[0][] = $bestFitExponential->getValueOfYForX($xValue); |
1745 | 1745 | } |
1746 | 1746 | |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | $aCount = 0; |
1775 | 1775 | foreach ($aArgs as $arg) { |
1776 | 1776 | // Is it a numeric value? |
1777 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1777 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1778 | 1778 | if ($arg <= 0) { |
1779 | 1779 | return PHPExcel_Calculation_Functions::NaN(); |
1780 | 1780 | } |
@@ -1810,10 +1810,10 @@ discard block |
||
1810 | 1810 | * |
1811 | 1811 | */ |
1812 | 1812 | public static function HYPGEOMDIST($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber) { |
1813 | - $sampleSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleSuccesses)); |
|
1814 | - $sampleNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleNumber)); |
|
1815 | - $populationSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationSuccesses)); |
|
1816 | - $populationNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationNumber)); |
|
1813 | + $sampleSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleSuccesses)); |
|
1814 | + $sampleNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleNumber)); |
|
1815 | + $populationSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationSuccesses)); |
|
1816 | + $populationNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationNumber)); |
|
1817 | 1817 | |
1818 | 1818 | if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) { |
1819 | 1819 | if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) { |
@@ -1825,9 +1825,9 @@ discard block |
||
1825 | 1825 | if (($populationSuccesses <= 0) || ($populationSuccesses > $populationNumber)) { |
1826 | 1826 | return PHPExcel_Calculation_Functions::NaN(); |
1827 | 1827 | } |
1828 | - return PHPExcel_Calculation_MathTrig::COMBIN($populationSuccesses,$sampleSuccesses) * |
|
1829 | - PHPExcel_Calculation_MathTrig::COMBIN($populationNumber - $populationSuccesses,$sampleNumber - $sampleSuccesses) / |
|
1830 | - PHPExcel_Calculation_MathTrig::COMBIN($populationNumber,$sampleNumber); |
|
1828 | + return PHPExcel_Calculation_MathTrig::COMBIN($populationSuccesses, $sampleSuccesses) * |
|
1829 | + PHPExcel_Calculation_MathTrig::COMBIN($populationNumber - $populationSuccesses, $sampleNumber - $sampleSuccesses) / |
|
1830 | + PHPExcel_Calculation_MathTrig::COMBIN($populationNumber, $sampleNumber); |
|
1831 | 1831 | } |
1832 | 1832 | return PHPExcel_Calculation_Functions::VALUE(); |
1833 | 1833 | } // function HYPGEOMDIST() |
@@ -1842,8 +1842,8 @@ discard block |
||
1842 | 1842 | * @param array of mixed Data Series X |
1843 | 1843 | * @return float |
1844 | 1844 | */ |
1845 | - public static function INTERCEPT($yValues,$xValues) { |
|
1846 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1845 | + public static function INTERCEPT($yValues, $xValues) { |
|
1846 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1847 | 1847 | return PHPExcel_Calculation_Functions::VALUE(); |
1848 | 1848 | } |
1849 | 1849 | $yValueCount = count($yValues); |
@@ -1855,7 +1855,7 @@ discard block |
||
1855 | 1855 | return PHPExcel_Calculation_Functions::DIV0(); |
1856 | 1856 | } |
1857 | 1857 | |
1858 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
1858 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
1859 | 1859 | return $bestFitLinear->getIntersect(); |
1860 | 1860 | } // function INTERCEPT() |
1861 | 1861 | |
@@ -1881,11 +1881,11 @@ discard block |
||
1881 | 1881 | // Loop through arguments |
1882 | 1882 | foreach ($aArgs as $k => $arg) { |
1883 | 1883 | if ((is_bool($arg)) && |
1884 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
1884 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
1885 | 1885 | } else { |
1886 | 1886 | // Is it a numeric value? |
1887 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1888 | - $summer += pow((($arg - $mean) / $stdDev),4) ; |
|
1887 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1888 | + $summer += pow((($arg - $mean) / $stdDev), 4); |
|
1889 | 1889 | ++$count; |
1890 | 1890 | } |
1891 | 1891 | } |
@@ -1893,7 +1893,7 @@ discard block |
||
1893 | 1893 | |
1894 | 1894 | // Return |
1895 | 1895 | if ($count > 3) { |
1896 | - return $summer * ($count * ($count+1) / (($count-1) * ($count-2) * ($count-3))) - (3 * pow($count-1,2) / (($count-2) * ($count-3))); |
|
1896 | + return $summer * ($count * ($count + 1) / (($count - 1) * ($count - 2) * ($count - 3))) - (3 * pow($count - 1, 2) / (($count - 2) * ($count - 3))); |
|
1897 | 1897 | } |
1898 | 1898 | } |
1899 | 1899 | return PHPExcel_Calculation_Functions::DIV0(); |
@@ -1922,11 +1922,11 @@ discard block |
||
1922 | 1922 | // Calculate |
1923 | 1923 | $entry = floor(array_pop($aArgs)); |
1924 | 1924 | |
1925 | - if ((is_numeric($entry)) && (!is_string($entry))) { |
|
1925 | + if ((is_numeric($entry)) && ( ! is_string($entry))) { |
|
1926 | 1926 | $mArgs = array(); |
1927 | 1927 | foreach ($aArgs as $arg) { |
1928 | 1928 | // Is it a numeric value? |
1929 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
1929 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
1930 | 1930 | $mArgs[] = $arg; |
1931 | 1931 | } |
1932 | 1932 | } |
@@ -1954,12 +1954,12 @@ discard block |
||
1954 | 1954 | * @param boolean A logical value specifying whether to return additional regression statistics. |
1955 | 1955 | * @return array |
1956 | 1956 | */ |
1957 | - public static function LINEST($yValues,$xValues=null,$const=True,$stats=False) { |
|
1958 | - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
1959 | - $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
|
1960 | - if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
1957 | + public static function LINEST($yValues, $xValues = null, $const = True, $stats = False) { |
|
1958 | + $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
1959 | + $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
|
1960 | + if (is_null($xValues)) $xValues = range(1, count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
1961 | 1961 | |
1962 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
1962 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
1963 | 1963 | return PHPExcel_Calculation_Functions::VALUE(); |
1964 | 1964 | } |
1965 | 1965 | $yValueCount = count($yValues); |
@@ -1972,15 +1972,15 @@ discard block |
||
1972 | 1972 | return 0; |
1973 | 1973 | } |
1974 | 1974 | |
1975 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const); |
|
1975 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues, $const); |
|
1976 | 1976 | if ($stats) { |
1977 | - return array( array( $bestFitLinear->getSlope(), |
|
1977 | + return array(array($bestFitLinear->getSlope(), |
|
1978 | 1978 | $bestFitLinear->getSlopeSE(), |
1979 | 1979 | $bestFitLinear->getGoodnessOfFit(), |
1980 | 1980 | $bestFitLinear->getF(), |
1981 | 1981 | $bestFitLinear->getSSRegression(), |
1982 | 1982 | ), |
1983 | - array( $bestFitLinear->getIntersect(), |
|
1983 | + array($bestFitLinear->getIntersect(), |
|
1984 | 1984 | $bestFitLinear->getIntersectSE(), |
1985 | 1985 | $bestFitLinear->getStdevOfResiduals(), |
1986 | 1986 | $bestFitLinear->getDFResiduals(), |
@@ -1988,7 +1988,7 @@ discard block |
||
1988 | 1988 | ) |
1989 | 1989 | ); |
1990 | 1990 | } else { |
1991 | - return array( $bestFitLinear->getSlope(), |
|
1991 | + return array($bestFitLinear->getSlope(), |
|
1992 | 1992 | $bestFitLinear->getIntersect() |
1993 | 1993 | ); |
1994 | 1994 | } |
@@ -2007,18 +2007,18 @@ discard block |
||
2007 | 2007 | * @param boolean A logical value specifying whether to return additional regression statistics. |
2008 | 2008 | * @return array |
2009 | 2009 | */ |
2010 | - public static function LOGEST($yValues,$xValues=null,$const=True,$stats=False) { |
|
2011 | - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
2012 | - $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
|
2013 | - if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
2010 | + public static function LOGEST($yValues, $xValues = null, $const = True, $stats = False) { |
|
2011 | + $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
2012 | + $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
|
2013 | + if (is_null($xValues)) $xValues = range(1, count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
2014 | 2014 | |
2015 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
2015 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
2016 | 2016 | return PHPExcel_Calculation_Functions::VALUE(); |
2017 | 2017 | } |
2018 | 2018 | $yValueCount = count($yValues); |
2019 | 2019 | $xValueCount = count($xValues); |
2020 | 2020 | |
2021 | - foreach($yValues as $value) { |
|
2021 | + foreach ($yValues as $value) { |
|
2022 | 2022 | if ($value <= 0.0) { |
2023 | 2023 | return PHPExcel_Calculation_Functions::NaN(); |
2024 | 2024 | } |
@@ -2031,15 +2031,15 @@ discard block |
||
2031 | 2031 | return 1; |
2032 | 2032 | } |
2033 | 2033 | |
2034 | - $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const); |
|
2034 | + $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL, $yValues, $xValues, $const); |
|
2035 | 2035 | if ($stats) { |
2036 | - return array( array( $bestFitExponential->getSlope(), |
|
2036 | + return array(array($bestFitExponential->getSlope(), |
|
2037 | 2037 | $bestFitExponential->getSlopeSE(), |
2038 | 2038 | $bestFitExponential->getGoodnessOfFit(), |
2039 | 2039 | $bestFitExponential->getF(), |
2040 | 2040 | $bestFitExponential->getSSRegression(), |
2041 | 2041 | ), |
2042 | - array( $bestFitExponential->getIntersect(), |
|
2042 | + array($bestFitExponential->getIntersect(), |
|
2043 | 2043 | $bestFitExponential->getIntersectSE(), |
2044 | 2044 | $bestFitExponential->getStdevOfResiduals(), |
2045 | 2045 | $bestFitExponential->getDFResiduals(), |
@@ -2047,7 +2047,7 @@ discard block |
||
2047 | 2047 | ) |
2048 | 2048 | ); |
2049 | 2049 | } else { |
2050 | - return array( $bestFitExponential->getSlope(), |
|
2050 | + return array($bestFitExponential->getSlope(), |
|
2051 | 2051 | $bestFitExponential->getIntersect() |
2052 | 2052 | ); |
2053 | 2053 | } |
@@ -2067,9 +2067,9 @@ discard block |
||
2067 | 2067 | * (as described at) http://home.online.no/~pjacklam/notes/invnorm/ |
2068 | 2068 | */ |
2069 | 2069 | public static function LOGINV($probability, $mean, $stdDev) { |
2070 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2071 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2072 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2070 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2071 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2072 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2073 | 2073 | |
2074 | 2074 | if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2075 | 2075 | if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) { |
@@ -2091,9 +2091,9 @@ discard block |
||
2091 | 2091 | * @return float |
2092 | 2092 | */ |
2093 | 2093 | public static function LOGNORMDIST($value, $mean, $stdDev) { |
2094 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2095 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2096 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2094 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2095 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2096 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2097 | 2097 | |
2098 | 2098 | if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2099 | 2099 | if (($value <= 0) || ($stdDev <= 0)) { |
@@ -2127,7 +2127,7 @@ discard block |
||
2127 | 2127 | $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
2128 | 2128 | foreach ($aArgs as $arg) { |
2129 | 2129 | // Is it a numeric value? |
2130 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2130 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2131 | 2131 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
2132 | 2132 | $returnValue = $arg; |
2133 | 2133 | } |
@@ -2135,7 +2135,7 @@ discard block |
||
2135 | 2135 | } |
2136 | 2136 | |
2137 | 2137 | // Return |
2138 | - if(is_null($returnValue)) { |
|
2138 | + if (is_null($returnValue)) { |
|
2139 | 2139 | return 0; |
2140 | 2140 | } |
2141 | 2141 | return $returnValue; |
@@ -2176,7 +2176,7 @@ discard block |
||
2176 | 2176 | } |
2177 | 2177 | |
2178 | 2178 | // Return |
2179 | - if(is_null($returnValue)) { |
|
2179 | + if (is_null($returnValue)) { |
|
2180 | 2180 | return 0; |
2181 | 2181 | } |
2182 | 2182 | return $returnValue; |
@@ -2197,7 +2197,7 @@ discard block |
||
2197 | 2197 | * @param string $condition The criteria that defines which cells will be checked. |
2198 | 2198 | * @return float |
2199 | 2199 | */ |
2200 | - public static function MAXIF($aArgs,$condition,$sumArgs = array()) { |
|
2200 | + public static function MAXIF($aArgs, $condition, $sumArgs = array()) { |
|
2201 | 2201 | // Return value |
2202 | 2202 | $returnValue = null; |
2203 | 2203 | |
@@ -2209,7 +2209,7 @@ discard block |
||
2209 | 2209 | $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); |
2210 | 2210 | // Loop through arguments |
2211 | 2211 | foreach ($aArgs as $key => $arg) { |
2212 | - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2212 | + if ( ! is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2213 | 2213 | $testCondition = '='.$arg.$condition; |
2214 | 2214 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
2215 | 2215 | if ((is_null($returnValue)) || ($arg > $returnValue)) { |
@@ -2245,14 +2245,14 @@ discard block |
||
2245 | 2245 | $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
2246 | 2246 | foreach ($aArgs as $arg) { |
2247 | 2247 | // Is it a numeric value? |
2248 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2248 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2249 | 2249 | $mArgs[] = $arg; |
2250 | 2250 | } |
2251 | 2251 | } |
2252 | 2252 | |
2253 | 2253 | $mValueCount = count($mArgs); |
2254 | 2254 | if ($mValueCount > 0) { |
2255 | - sort($mArgs,SORT_NUMERIC); |
|
2255 | + sort($mArgs, SORT_NUMERIC); |
|
2256 | 2256 | $mValueCount = $mValueCount / 2; |
2257 | 2257 | if ($mValueCount == floor($mValueCount)) { |
2258 | 2258 | $returnValue = ($mArgs[$mValueCount--] + $mArgs[$mValueCount]) / 2; |
@@ -2289,7 +2289,7 @@ discard block |
||
2289 | 2289 | $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
2290 | 2290 | foreach ($aArgs as $arg) { |
2291 | 2291 | // Is it a numeric value? |
2292 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2292 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2293 | 2293 | if ((is_null($returnValue)) || ($arg < $returnValue)) { |
2294 | 2294 | $returnValue = $arg; |
2295 | 2295 | } |
@@ -2297,7 +2297,7 @@ discard block |
||
2297 | 2297 | } |
2298 | 2298 | |
2299 | 2299 | // Return |
2300 | - if(is_null($returnValue)) { |
|
2300 | + if (is_null($returnValue)) { |
|
2301 | 2301 | return 0; |
2302 | 2302 | } |
2303 | 2303 | return $returnValue; |
@@ -2338,7 +2338,7 @@ discard block |
||
2338 | 2338 | } |
2339 | 2339 | |
2340 | 2340 | // Return |
2341 | - if(is_null($returnValue)) { |
|
2341 | + if (is_null($returnValue)) { |
|
2342 | 2342 | return 0; |
2343 | 2343 | } |
2344 | 2344 | return $returnValue; |
@@ -2359,7 +2359,7 @@ discard block |
||
2359 | 2359 | * @param string $condition The criteria that defines which cells will be checked. |
2360 | 2360 | * @return float |
2361 | 2361 | */ |
2362 | - public static function MINIF($aArgs,$condition,$sumArgs = array()) { |
|
2362 | + public static function MINIF($aArgs, $condition, $sumArgs = array()) { |
|
2363 | 2363 | // Return value |
2364 | 2364 | $returnValue = null; |
2365 | 2365 | |
@@ -2371,7 +2371,7 @@ discard block |
||
2371 | 2371 | $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); |
2372 | 2372 | // Loop through arguments |
2373 | 2373 | foreach ($aArgs as $key => $arg) { |
2374 | - if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2374 | + if ( ! is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); } |
|
2375 | 2375 | $testCondition = '='.$arg.$condition; |
2376 | 2376 | if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) { |
2377 | 2377 | if ((is_null($returnValue)) || ($arg < $returnValue)) { |
@@ -2391,22 +2391,22 @@ discard block |
||
2391 | 2391 | // |
2392 | 2392 | private static function _modeCalc($data) { |
2393 | 2393 | $frequencyArray = array(); |
2394 | - foreach($data as $datum) { |
|
2394 | + foreach ($data as $datum) { |
|
2395 | 2395 | $found = False; |
2396 | - foreach($frequencyArray as $key => $value) { |
|
2396 | + foreach ($frequencyArray as $key => $value) { |
|
2397 | 2397 | if ((string) $value['value'] == (string) $datum) { |
2398 | 2398 | ++$frequencyArray[$key]['frequency']; |
2399 | 2399 | $found = True; |
2400 | 2400 | break; |
2401 | 2401 | } |
2402 | 2402 | } |
2403 | - if (!$found) { |
|
2403 | + if ( ! $found) { |
|
2404 | 2404 | $frequencyArray[] = array('value' => $datum, |
2405 | - 'frequency' => 1 ); |
|
2405 | + 'frequency' => 1); |
|
2406 | 2406 | } |
2407 | 2407 | } |
2408 | 2408 | |
2409 | - foreach($frequencyArray as $key => $value) { |
|
2409 | + foreach ($frequencyArray as $key => $value) { |
|
2410 | 2410 | $frequencyList[$key] = $value['frequency']; |
2411 | 2411 | $valueList[$key] = $value['value']; |
2412 | 2412 | } |
@@ -2442,12 +2442,12 @@ discard block |
||
2442 | 2442 | $mArgs = array(); |
2443 | 2443 | foreach ($aArgs as $arg) { |
2444 | 2444 | // Is it a numeric value? |
2445 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2445 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2446 | 2446 | $mArgs[] = $arg; |
2447 | 2447 | } |
2448 | 2448 | } |
2449 | 2449 | |
2450 | - if (!empty($mArgs)) { |
|
2450 | + if ( ! empty($mArgs)) { |
|
2451 | 2451 | return self::_modeCalc($mArgs); |
2452 | 2452 | } |
2453 | 2453 | |
@@ -2472,9 +2472,9 @@ discard block |
||
2472 | 2472 | * |
2473 | 2473 | */ |
2474 | 2474 | public static function NEGBINOMDIST($failures, $successes, $probability) { |
2475 | - $failures = floor(PHPExcel_Calculation_Functions::flattenSingleValue($failures)); |
|
2476 | - $successes = floor(PHPExcel_Calculation_Functions::flattenSingleValue($successes)); |
|
2477 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2475 | + $failures = floor(PHPExcel_Calculation_Functions::flattenSingleValue($failures)); |
|
2476 | + $successes = floor(PHPExcel_Calculation_Functions::flattenSingleValue($successes)); |
|
2477 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2478 | 2478 | |
2479 | 2479 | if ((is_numeric($failures)) && (is_numeric($successes)) && (is_numeric($probability))) { |
2480 | 2480 | if (($failures < 0) || ($successes < 1)) { |
@@ -2488,7 +2488,7 @@ discard block |
||
2488 | 2488 | return PHPExcel_Calculation_Functions::NaN(); |
2489 | 2489 | } |
2490 | 2490 | } |
2491 | - return (PHPExcel_Calculation_MathTrig::COMBIN($failures + $successes - 1,$successes - 1)) * (pow($probability,$successes)) * (pow(1 - $probability,$failures)) ; |
|
2491 | + return (PHPExcel_Calculation_MathTrig::COMBIN($failures + $successes - 1, $successes - 1)) * (pow($probability, $successes)) * (pow(1 - $probability, $failures)); |
|
2492 | 2492 | } |
2493 | 2493 | return PHPExcel_Calculation_Functions::VALUE(); |
2494 | 2494 | } // function NEGBINOMDIST() |
@@ -2509,9 +2509,9 @@ discard block |
||
2509 | 2509 | * |
2510 | 2510 | */ |
2511 | 2511 | public static function NORMDIST($value, $mean, $stdDev, $cumulative) { |
2512 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2513 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2514 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2512 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2513 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2514 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2515 | 2515 | |
2516 | 2516 | if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2517 | 2517 | if ($stdDev < 0) { |
@@ -2521,7 +2521,7 @@ discard block |
||
2521 | 2521 | if ($cumulative) { |
2522 | 2522 | return 0.5 * (1 + PHPExcel_Calculation_Engineering::_erfVal(($value - $mean) / ($stdDev * sqrt(2)))); |
2523 | 2523 | } else { |
2524 | - return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean,2) / (2 * ($stdDev * $stdDev)))); |
|
2524 | + return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean, 2) / (2 * ($stdDev * $stdDev)))); |
|
2525 | 2525 | } |
2526 | 2526 | } |
2527 | 2527 | } |
@@ -2540,10 +2540,10 @@ discard block |
||
2540 | 2540 | * @return float |
2541 | 2541 | * |
2542 | 2542 | */ |
2543 | - public static function NORMINV($probability,$mean,$stdDev) { |
|
2544 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2545 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2546 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2543 | + public static function NORMINV($probability, $mean, $stdDev) { |
|
2544 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
2545 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2546 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2547 | 2547 | |
2548 | 2548 | if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2549 | 2549 | if (($probability < 0) || ($probability > 1)) { |
@@ -2569,7 +2569,7 @@ discard block |
||
2569 | 2569 | * @return float |
2570 | 2570 | */ |
2571 | 2571 | public static function NORMSDIST($value) { |
2572 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2572 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2573 | 2573 | |
2574 | 2574 | return self::NORMDIST($value, 0, 1, True); |
2575 | 2575 | } // function NORMSDIST() |
@@ -2608,14 +2608,14 @@ discard block |
||
2608 | 2608 | // Calculate |
2609 | 2609 | $entry = array_pop($aArgs); |
2610 | 2610 | |
2611 | - if ((is_numeric($entry)) && (!is_string($entry))) { |
|
2611 | + if ((is_numeric($entry)) && ( ! is_string($entry))) { |
|
2612 | 2612 | if (($entry < 0) || ($entry > 1)) { |
2613 | 2613 | return PHPExcel_Calculation_Functions::NaN(); |
2614 | 2614 | } |
2615 | 2615 | $mArgs = array(); |
2616 | 2616 | foreach ($aArgs as $arg) { |
2617 | 2617 | // Is it a numeric value? |
2618 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2618 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2619 | 2619 | $mArgs[] = $arg; |
2620 | 2620 | } |
2621 | 2621 | } |
@@ -2623,14 +2623,14 @@ discard block |
||
2623 | 2623 | if ($mValueCount > 0) { |
2624 | 2624 | sort($mArgs); |
2625 | 2625 | $count = self::COUNT($mArgs); |
2626 | - $index = $entry * ($count-1); |
|
2626 | + $index = $entry * ($count - 1); |
|
2627 | 2627 | $iBase = floor($index); |
2628 | 2628 | if ($index == $iBase) { |
2629 | 2629 | return $mArgs[$index]; |
2630 | 2630 | } else { |
2631 | 2631 | $iNext = $iBase + 1; |
2632 | 2632 | $iProportion = $index - $iBase; |
2633 | - return $mArgs[$iBase] + (($mArgs[$iNext] - $mArgs[$iBase]) * $iProportion) ; |
|
2633 | + return $mArgs[$iBase] + (($mArgs[$iNext] - $mArgs[$iBase]) * $iProportion); |
|
2634 | 2634 | } |
2635 | 2635 | } |
2636 | 2636 | } |
@@ -2648,17 +2648,17 @@ discard block |
||
2648 | 2648 | * @param number The number of significant digits for the returned percentage value. |
2649 | 2649 | * @return float |
2650 | 2650 | */ |
2651 | - public static function PERCENTRANK($valueSet,$value,$significance=3) { |
|
2652 | - $valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet); |
|
2653 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2654 | - $significance = (is_null($significance)) ? 3 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($significance); |
|
2651 | + public static function PERCENTRANK($valueSet, $value, $significance = 3) { |
|
2652 | + $valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet); |
|
2653 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2654 | + $significance = (is_null($significance)) ? 3 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($significance); |
|
2655 | 2655 | |
2656 | - foreach($valueSet as $key => $valueEntry) { |
|
2657 | - if (!is_numeric($valueEntry)) { |
|
2656 | + foreach ($valueSet as $key => $valueEntry) { |
|
2657 | + if ( ! is_numeric($valueEntry)) { |
|
2658 | 2658 | unset($valueSet[$key]); |
2659 | 2659 | } |
2660 | 2660 | } |
2661 | - sort($valueSet,SORT_NUMERIC); |
|
2661 | + sort($valueSet, SORT_NUMERIC); |
|
2662 | 2662 | $valueCount = count($valueSet); |
2663 | 2663 | if ($valueCount == 0) { |
2664 | 2664 | return PHPExcel_Calculation_Functions::NaN(); |
@@ -2669,7 +2669,7 @@ discard block |
||
2669 | 2669 | return PHPExcel_Calculation_Functions::NA(); |
2670 | 2670 | } |
2671 | 2671 | |
2672 | - $pos = array_search($value,$valueSet); |
|
2672 | + $pos = array_search($value, $valueSet); |
|
2673 | 2673 | if ($pos === False) { |
2674 | 2674 | $pos = 0; |
2675 | 2675 | $testValue = $valueSet[0]; |
@@ -2680,7 +2680,7 @@ discard block |
||
2680 | 2680 | $pos += (($value - $valueSet[$pos]) / ($testValue - $valueSet[$pos])); |
2681 | 2681 | } |
2682 | 2682 | |
2683 | - return round($pos / $valueAdjustor,$significance); |
|
2683 | + return round($pos / $valueAdjustor, $significance); |
|
2684 | 2684 | } // function PERCENTRANK() |
2685 | 2685 | |
2686 | 2686 | |
@@ -2697,9 +2697,9 @@ discard block |
||
2697 | 2697 | * @param int $numInSet Number of objects in each permutation |
2698 | 2698 | * @return int Number of permutations |
2699 | 2699 | */ |
2700 | - public static function PERMUT($numObjs,$numInSet) { |
|
2701 | - $numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs); |
|
2702 | - $numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet); |
|
2700 | + public static function PERMUT($numObjs, $numInSet) { |
|
2701 | + $numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs); |
|
2702 | + $numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet); |
|
2703 | 2703 | |
2704 | 2704 | if ((is_numeric($numObjs)) && (is_numeric($numInSet))) { |
2705 | 2705 | $numInSet = floor($numInSet); |
@@ -2726,8 +2726,8 @@ discard block |
||
2726 | 2726 | * |
2727 | 2727 | */ |
2728 | 2728 | public static function POISSON($value, $mean, $cumulative) { |
2729 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2730 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2729 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2730 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2731 | 2731 | |
2732 | 2732 | if ((is_numeric($value)) && (is_numeric($mean))) { |
2733 | 2733 | if (($value <= 0) || ($mean <= 0)) { |
@@ -2737,11 +2737,11 @@ discard block |
||
2737 | 2737 | if ($cumulative) { |
2738 | 2738 | $summer = 0; |
2739 | 2739 | for ($i = 0; $i <= floor($value); ++$i) { |
2740 | - $summer += pow($mean,$i) / PHPExcel_Calculation_MathTrig::FACT($i); |
|
2740 | + $summer += pow($mean, $i) / PHPExcel_Calculation_MathTrig::FACT($i); |
|
2741 | 2741 | } |
2742 | - return exp(0-$mean) * $summer; |
|
2742 | + return exp(0 - $mean) * $summer; |
|
2743 | 2743 | } else { |
2744 | - return (exp(0-$mean) * pow($mean,$value)) / PHPExcel_Calculation_MathTrig::FACT($value); |
|
2744 | + return (exp(0 - $mean) * pow($mean, $value)) / PHPExcel_Calculation_MathTrig::FACT($value); |
|
2745 | 2745 | } |
2746 | 2746 | } |
2747 | 2747 | } |
@@ -2769,12 +2769,12 @@ discard block |
||
2769 | 2769 | // Calculate |
2770 | 2770 | $entry = floor(array_pop($aArgs)); |
2771 | 2771 | |
2772 | - if ((is_numeric($entry)) && (!is_string($entry))) { |
|
2772 | + if ((is_numeric($entry)) && ( ! is_string($entry))) { |
|
2773 | 2773 | $entry /= 4; |
2774 | 2774 | if (($entry < 0) || ($entry > 1)) { |
2775 | 2775 | return PHPExcel_Calculation_Functions::NaN(); |
2776 | 2776 | } |
2777 | - return self::PERCENTILE($aArgs,$entry); |
|
2777 | + return self::PERCENTILE($aArgs, $entry); |
|
2778 | 2778 | } |
2779 | 2779 | return PHPExcel_Calculation_Functions::VALUE(); |
2780 | 2780 | } // function QUARTILE() |
@@ -2790,23 +2790,23 @@ discard block |
||
2790 | 2790 | * @param mixed Order to sort the values in the value set |
2791 | 2791 | * @return float |
2792 | 2792 | */ |
2793 | - public static function RANK($value,$valueSet,$order=0) { |
|
2793 | + public static function RANK($value, $valueSet, $order = 0) { |
|
2794 | 2794 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
2795 | 2795 | $valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet); |
2796 | - $order = (is_null($order)) ? 0 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($order); |
|
2796 | + $order = (is_null($order)) ? 0 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($order); |
|
2797 | 2797 | |
2798 | - foreach($valueSet as $key => $valueEntry) { |
|
2799 | - if (!is_numeric($valueEntry)) { |
|
2798 | + foreach ($valueSet as $key => $valueEntry) { |
|
2799 | + if ( ! is_numeric($valueEntry)) { |
|
2800 | 2800 | unset($valueSet[$key]); |
2801 | 2801 | } |
2802 | 2802 | } |
2803 | 2803 | |
2804 | 2804 | if ($order == 0) { |
2805 | - rsort($valueSet,SORT_NUMERIC); |
|
2805 | + rsort($valueSet, SORT_NUMERIC); |
|
2806 | 2806 | } else { |
2807 | - sort($valueSet,SORT_NUMERIC); |
|
2807 | + sort($valueSet, SORT_NUMERIC); |
|
2808 | 2808 | } |
2809 | - $pos = array_search($value,$valueSet); |
|
2809 | + $pos = array_search($value, $valueSet); |
|
2810 | 2810 | if ($pos === False) { |
2811 | 2811 | return PHPExcel_Calculation_Functions::NA(); |
2812 | 2812 | } |
@@ -2824,8 +2824,8 @@ discard block |
||
2824 | 2824 | * @param array of mixed Data Series X |
2825 | 2825 | * @return float |
2826 | 2826 | */ |
2827 | - public static function RSQ($yValues,$xValues) { |
|
2828 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
2827 | + public static function RSQ($yValues, $xValues) { |
|
2828 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
2829 | 2829 | return PHPExcel_Calculation_Functions::VALUE(); |
2830 | 2830 | } |
2831 | 2831 | $yValueCount = count($yValues); |
@@ -2837,7 +2837,7 @@ discard block |
||
2837 | 2837 | return PHPExcel_Calculation_Functions::DIV0(); |
2838 | 2838 | } |
2839 | 2839 | |
2840 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
2840 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
2841 | 2841 | return $bestFitLinear->getGoodnessOfFit(); |
2842 | 2842 | } // function RSQ() |
2843 | 2843 | |
@@ -2862,11 +2862,11 @@ discard block |
||
2862 | 2862 | // Loop through arguments |
2863 | 2863 | foreach ($aArgs as $k => $arg) { |
2864 | 2864 | if ((is_bool($arg)) && |
2865 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
2865 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
2866 | 2866 | } else { |
2867 | 2867 | // Is it a numeric value? |
2868 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2869 | - $summer += pow((($arg - $mean) / $stdDev),3) ; |
|
2868 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2869 | + $summer += pow((($arg - $mean) / $stdDev), 3); |
|
2870 | 2870 | ++$count; |
2871 | 2871 | } |
2872 | 2872 | } |
@@ -2874,7 +2874,7 @@ discard block |
||
2874 | 2874 | |
2875 | 2875 | // Return |
2876 | 2876 | if ($count > 2) { |
2877 | - return $summer * ($count / (($count-1) * ($count-2))); |
|
2877 | + return $summer * ($count / (($count - 1) * ($count - 2))); |
|
2878 | 2878 | } |
2879 | 2879 | return PHPExcel_Calculation_Functions::DIV0(); |
2880 | 2880 | } // function SKEW() |
@@ -2889,8 +2889,8 @@ discard block |
||
2889 | 2889 | * @param array of mixed Data Series X |
2890 | 2890 | * @return float |
2891 | 2891 | */ |
2892 | - public static function SLOPE($yValues,$xValues) { |
|
2893 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
2892 | + public static function SLOPE($yValues, $xValues) { |
|
2893 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
2894 | 2894 | return PHPExcel_Calculation_Functions::VALUE(); |
2895 | 2895 | } |
2896 | 2896 | $yValueCount = count($yValues); |
@@ -2902,7 +2902,7 @@ discard block |
||
2902 | 2902 | return PHPExcel_Calculation_Functions::DIV0(); |
2903 | 2903 | } |
2904 | 2904 | |
2905 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
2905 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
2906 | 2906 | return $bestFitLinear->getSlope(); |
2907 | 2907 | } // function SLOPE() |
2908 | 2908 | |
@@ -2928,11 +2928,11 @@ discard block |
||
2928 | 2928 | // Calculate |
2929 | 2929 | $entry = array_pop($aArgs); |
2930 | 2930 | |
2931 | - if ((is_numeric($entry)) && (!is_string($entry))) { |
|
2931 | + if ((is_numeric($entry)) && ( ! is_string($entry))) { |
|
2932 | 2932 | $mArgs = array(); |
2933 | 2933 | foreach ($aArgs as $arg) { |
2934 | 2934 | // Is it a numeric value? |
2935 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
2935 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
2936 | 2936 | $mArgs[] = $arg; |
2937 | 2937 | } |
2938 | 2938 | } |
@@ -2958,16 +2958,16 @@ discard block |
||
2958 | 2958 | * @param float $stdDev Standard Deviation |
2959 | 2959 | * @return float Standardized value |
2960 | 2960 | */ |
2961 | - public static function STANDARDIZE($value,$mean,$stdDev) { |
|
2962 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2963 | - $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2964 | - $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2961 | + public static function STANDARDIZE($value, $mean, $stdDev) { |
|
2962 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
2963 | + $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); |
|
2964 | + $stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev); |
|
2965 | 2965 | |
2966 | 2966 | if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) { |
2967 | 2967 | if ($stdDev <= 0) { |
2968 | 2968 | return PHPExcel_Calculation_Functions::NaN(); |
2969 | 2969 | } |
2970 | - return ($value - $mean) / $stdDev ; |
|
2970 | + return ($value - $mean) / $stdDev; |
|
2971 | 2971 | } |
2972 | 2972 | return PHPExcel_Calculation_Functions::VALUE(); |
2973 | 2973 | } // function STANDARDIZE() |
@@ -2994,19 +2994,19 @@ discard block |
||
2994 | 2994 | $returnValue = null; |
2995 | 2995 | |
2996 | 2996 | $aMean = self::AVERAGE($aArgs); |
2997 | - if (!is_null($aMean)) { |
|
2997 | + if ( ! is_null($aMean)) { |
|
2998 | 2998 | $aCount = -1; |
2999 | 2999 | foreach ($aArgs as $k => $arg) { |
3000 | 3000 | if ((is_bool($arg)) && |
3001 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3001 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3002 | 3002 | $arg = (integer) $arg; |
3003 | 3003 | } |
3004 | 3004 | // Is it a numeric value? |
3005 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3005 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3006 | 3006 | if (is_null($returnValue)) { |
3007 | - $returnValue = pow(($arg - $aMean),2); |
|
3007 | + $returnValue = pow(($arg - $aMean), 2); |
|
3008 | 3008 | } else { |
3009 | - $returnValue += pow(($arg - $aMean),2); |
|
3009 | + $returnValue += pow(($arg - $aMean), 2); |
|
3010 | 3010 | } |
3011 | 3011 | ++$aCount; |
3012 | 3012 | } |
@@ -3041,11 +3041,11 @@ discard block |
||
3041 | 3041 | $returnValue = null; |
3042 | 3042 | |
3043 | 3043 | $aMean = self::AVERAGEA($aArgs); |
3044 | - if (!is_null($aMean)) { |
|
3044 | + if ( ! is_null($aMean)) { |
|
3045 | 3045 | $aCount = -1; |
3046 | 3046 | foreach ($aArgs as $k => $arg) { |
3047 | 3047 | if ((is_bool($arg)) && |
3048 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3048 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3049 | 3049 | } else { |
3050 | 3050 | // Is it a numeric value? |
3051 | 3051 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
@@ -3055,9 +3055,9 @@ discard block |
||
3055 | 3055 | $arg = 0; |
3056 | 3056 | } |
3057 | 3057 | if (is_null($returnValue)) { |
3058 | - $returnValue = pow(($arg - $aMean),2); |
|
3058 | + $returnValue = pow(($arg - $aMean), 2); |
|
3059 | 3059 | } else { |
3060 | - $returnValue += pow(($arg - $aMean),2); |
|
3060 | + $returnValue += pow(($arg - $aMean), 2); |
|
3061 | 3061 | } |
3062 | 3062 | ++$aCount; |
3063 | 3063 | } |
@@ -3093,19 +3093,19 @@ discard block |
||
3093 | 3093 | $returnValue = null; |
3094 | 3094 | |
3095 | 3095 | $aMean = self::AVERAGE($aArgs); |
3096 | - if (!is_null($aMean)) { |
|
3096 | + if ( ! is_null($aMean)) { |
|
3097 | 3097 | $aCount = 0; |
3098 | 3098 | foreach ($aArgs as $k => $arg) { |
3099 | 3099 | if ((is_bool($arg)) && |
3100 | - ((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3100 | + (( ! PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) { |
|
3101 | 3101 | $arg = (integer) $arg; |
3102 | 3102 | } |
3103 | 3103 | // Is it a numeric value? |
3104 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3104 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3105 | 3105 | if (is_null($returnValue)) { |
3106 | - $returnValue = pow(($arg - $aMean),2); |
|
3106 | + $returnValue = pow(($arg - $aMean), 2); |
|
3107 | 3107 | } else { |
3108 | - $returnValue += pow(($arg - $aMean),2); |
|
3108 | + $returnValue += pow(($arg - $aMean), 2); |
|
3109 | 3109 | } |
3110 | 3110 | ++$aCount; |
3111 | 3111 | } |
@@ -3140,11 +3140,11 @@ discard block |
||
3140 | 3140 | $returnValue = null; |
3141 | 3141 | |
3142 | 3142 | $aMean = self::AVERAGEA($aArgs); |
3143 | - if (!is_null($aMean)) { |
|
3143 | + if ( ! is_null($aMean)) { |
|
3144 | 3144 | $aCount = 0; |
3145 | 3145 | foreach ($aArgs as $k => $arg) { |
3146 | 3146 | if ((is_bool($arg)) && |
3147 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3147 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3148 | 3148 | } else { |
3149 | 3149 | // Is it a numeric value? |
3150 | 3150 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
@@ -3154,9 +3154,9 @@ discard block |
||
3154 | 3154 | $arg = 0; |
3155 | 3155 | } |
3156 | 3156 | if (is_null($returnValue)) { |
3157 | - $returnValue = pow(($arg - $aMean),2); |
|
3157 | + $returnValue = pow(($arg - $aMean), 2); |
|
3158 | 3158 | } else { |
3159 | - $returnValue += pow(($arg - $aMean),2); |
|
3159 | + $returnValue += pow(($arg - $aMean), 2); |
|
3160 | 3160 | } |
3161 | 3161 | ++$aCount; |
3162 | 3162 | } |
@@ -3181,8 +3181,8 @@ discard block |
||
3181 | 3181 | * @param array of mixed Data Series X |
3182 | 3182 | * @return float |
3183 | 3183 | */ |
3184 | - public static function STEYX($yValues,$xValues) { |
|
3185 | - if (!self::_checkTrendArrays($yValues,$xValues)) { |
|
3184 | + public static function STEYX($yValues, $xValues) { |
|
3185 | + if ( ! self::_checkTrendArrays($yValues, $xValues)) { |
|
3186 | 3186 | return PHPExcel_Calculation_Functions::VALUE(); |
3187 | 3187 | } |
3188 | 3188 | $yValueCount = count($yValues); |
@@ -3194,7 +3194,7 @@ discard block |
||
3194 | 3194 | return PHPExcel_Calculation_Functions::DIV0(); |
3195 | 3195 | } |
3196 | 3196 | |
3197 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues); |
|
3197 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues); |
|
3198 | 3198 | return $bestFitLinear->getStdevOfResiduals(); |
3199 | 3199 | } // function STEYX() |
3200 | 3200 | |
@@ -3211,7 +3211,7 @@ discard block |
||
3211 | 3211 | */ |
3212 | 3212 | public static function TDIST($value, $degrees, $tails) { |
3213 | 3213 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
3214 | - $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
3214 | + $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
3215 | 3215 | $tails = floor(PHPExcel_Calculation_Functions::flattenSingleValue($tails)); |
3216 | 3216 | |
3217 | 3217 | if ((is_numeric($value)) && (is_numeric($degrees)) && (is_numeric($tails))) { |
@@ -3228,7 +3228,7 @@ discard block |
||
3228 | 3228 | // Algorithms", editied by P Griffiths and I D Hill (1985; Ellis |
3229 | 3229 | // Horwood Ltd.; W. Sussex, England). |
3230 | 3230 | $tterm = $degrees; |
3231 | - $ttheta = atan2($value,sqrt($tterm)); |
|
3231 | + $ttheta = atan2($value, sqrt($tterm)); |
|
3232 | 3232 | $tc = cos($ttheta); |
3233 | 3233 | $ts = sin($ttheta); |
3234 | 3234 | $tsum = 0; |
@@ -3270,15 +3270,15 @@ discard block |
||
3270 | 3270 | * @return float |
3271 | 3271 | */ |
3272 | 3272 | public static function TINV($probability, $degrees) { |
3273 | - $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
3274 | - $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
3273 | + $probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability); |
|
3274 | + $degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees)); |
|
3275 | 3275 | |
3276 | 3276 | if ((is_numeric($probability)) && (is_numeric($degrees))) { |
3277 | 3277 | $xLo = 100; |
3278 | 3278 | $xHi = 0; |
3279 | 3279 | |
3280 | 3280 | $x = $xNew = 1; |
3281 | - $dx = 1; |
|
3281 | + $dx = 1; |
|
3282 | 3282 | $i = 0; |
3283 | 3283 | |
3284 | 3284 | while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) { |
@@ -3309,7 +3309,7 @@ discard block |
||
3309 | 3309 | if ($i == MAX_ITERATIONS) { |
3310 | 3310 | return PHPExcel_Calculation_Functions::NA(); |
3311 | 3311 | } |
3312 | - return round($x,12); |
|
3312 | + return round($x, 12); |
|
3313 | 3313 | } |
3314 | 3314 | return PHPExcel_Calculation_Functions::VALUE(); |
3315 | 3315 | } // function TINV() |
@@ -3326,19 +3326,19 @@ discard block |
||
3326 | 3326 | * @param boolean A logical value specifying whether to force the intersect to equal 0. |
3327 | 3327 | * @return array of float |
3328 | 3328 | */ |
3329 | - public static function TREND($yValues,$xValues=array(),$newValues=array(),$const=True) { |
|
3329 | + public static function TREND($yValues, $xValues = array(), $newValues = array(), $const = True) { |
|
3330 | 3330 | $yValues = PHPExcel_Calculation_Functions::flattenArray($yValues); |
3331 | 3331 | $xValues = PHPExcel_Calculation_Functions::flattenArray($xValues); |
3332 | 3332 | $newValues = PHPExcel_Calculation_Functions::flattenArray($newValues); |
3333 | - $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
3333 | + $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
|
3334 | 3334 | |
3335 | - $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const); |
|
3335 | + $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR, $yValues, $xValues, $const); |
|
3336 | 3336 | if (empty($newValues)) { |
3337 | 3337 | $newValues = $bestFitLinear->getXValues(); |
3338 | 3338 | } |
3339 | 3339 | |
3340 | 3340 | $returnArray = array(); |
3341 | - foreach($newValues as $xValue) { |
|
3341 | + foreach ($newValues as $xValue) { |
|
3342 | 3342 | $returnArray[0][] = $bestFitLinear->getValueOfYForX($xValue); |
3343 | 3343 | } |
3344 | 3344 | |
@@ -3368,20 +3368,20 @@ discard block |
||
3368 | 3368 | // Calculate |
3369 | 3369 | $percent = array_pop($aArgs); |
3370 | 3370 | |
3371 | - if ((is_numeric($percent)) && (!is_string($percent))) { |
|
3371 | + if ((is_numeric($percent)) && ( ! is_string($percent))) { |
|
3372 | 3372 | if (($percent < 0) || ($percent > 1)) { |
3373 | 3373 | return PHPExcel_Calculation_Functions::NaN(); |
3374 | 3374 | } |
3375 | 3375 | $mArgs = array(); |
3376 | 3376 | foreach ($aArgs as $arg) { |
3377 | 3377 | // Is it a numeric value? |
3378 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3378 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3379 | 3379 | $mArgs[] = $arg; |
3380 | 3380 | } |
3381 | 3381 | } |
3382 | 3382 | $discard = floor(self::COUNT($mArgs) * $percent / 2); |
3383 | 3383 | sort($mArgs); |
3384 | - for ($i=0; $i < $discard; ++$i) { |
|
3384 | + for ($i = 0; $i < $discard; ++$i) { |
|
3385 | 3385 | array_pop($mArgs); |
3386 | 3386 | array_shift($mArgs); |
3387 | 3387 | } |
@@ -3416,7 +3416,7 @@ discard block |
||
3416 | 3416 | foreach ($aArgs as $arg) { |
3417 | 3417 | if (is_bool($arg)) { $arg = (integer) $arg; } |
3418 | 3418 | // Is it a numeric value? |
3419 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3419 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3420 | 3420 | $summerA += ($arg * $arg); |
3421 | 3421 | $summerB += $arg; |
3422 | 3422 | ++$aCount; |
@@ -3460,7 +3460,7 @@ discard block |
||
3460 | 3460 | (PHPExcel_Calculation_Functions::isValue($k))) { |
3461 | 3461 | return PHPExcel_Calculation_Functions::VALUE(); |
3462 | 3462 | } elseif ((is_string($arg)) && |
3463 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3463 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3464 | 3464 | } else { |
3465 | 3465 | // Is it a numeric value? |
3466 | 3466 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
@@ -3511,7 +3511,7 @@ discard block |
||
3511 | 3511 | foreach ($aArgs as $arg) { |
3512 | 3512 | if (is_bool($arg)) { $arg = (integer) $arg; } |
3513 | 3513 | // Is it a numeric value? |
3514 | - if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3514 | + if ((is_numeric($arg)) && ( ! is_string($arg))) { |
|
3515 | 3515 | $summerA += ($arg * $arg); |
3516 | 3516 | $summerB += $arg; |
3517 | 3517 | ++$aCount; |
@@ -3555,7 +3555,7 @@ discard block |
||
3555 | 3555 | (PHPExcel_Calculation_Functions::isValue($k))) { |
3556 | 3556 | return PHPExcel_Calculation_Functions::VALUE(); |
3557 | 3557 | } elseif ((is_string($arg)) && |
3558 | - (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3558 | + ( ! PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3559 | 3559 | } else { |
3560 | 3560 | // Is it a numeric value? |
3561 | 3561 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
@@ -3597,7 +3597,7 @@ discard block |
||
3597 | 3597 | public static function WEIBULL($value, $alpha, $beta, $cumulative) { |
3598 | 3598 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
3599 | 3599 | $alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha); |
3600 | - $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
|
3600 | + $beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta); |
|
3601 | 3601 | |
3602 | 3602 | if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta))) { |
3603 | 3603 | if (($value < 0) || ($alpha <= 0) || ($beta <= 0)) { |
@@ -3605,9 +3605,9 @@ discard block |
||
3605 | 3605 | } |
3606 | 3606 | if ((is_numeric($cumulative)) || (is_bool($cumulative))) { |
3607 | 3607 | if ($cumulative) { |
3608 | - return 1 - exp(0 - pow($value / $beta,$alpha)); |
|
3608 | + return 1 - exp(0 - pow($value / $beta, $alpha)); |
|
3609 | 3609 | } else { |
3610 | - return ($alpha / pow($beta,$alpha)) * pow($value,$alpha - 1) * exp(0 - pow($value / $beta,$alpha)); |
|
3610 | + return ($alpha / pow($beta, $alpha)) * pow($value, $alpha - 1) * exp(0 - pow($value / $beta, $alpha)); |
|
3611 | 3611 | } |
3612 | 3612 | } |
3613 | 3613 | } |
@@ -3628,9 +3628,9 @@ discard block |
||
3628 | 3628 | * @return float |
3629 | 3629 | * |
3630 | 3630 | */ |
3631 | - public static function ZTEST($dataSet, $m0, $sigma=null) { |
|
3632 | - $dataSet = PHPExcel_Calculation_Functions::flattenArrayIndexed($dataSet); |
|
3633 | - $m0 = PHPExcel_Calculation_Functions::flattenSingleValue($m0); |
|
3631 | + public static function ZTEST($dataSet, $m0, $sigma = null) { |
|
3632 | + $dataSet = PHPExcel_Calculation_Functions::flattenArrayIndexed($dataSet); |
|
3633 | + $m0 = PHPExcel_Calculation_Functions::flattenSingleValue($m0); |
|
3634 | 3634 | $sigma = PHPExcel_Calculation_Functions::flattenSingleValue($sigma); |
3635 | 3635 | |
3636 | 3636 | if (is_null($sigma)) { |
@@ -3638,7 +3638,7 @@ discard block |
||
3638 | 3638 | } |
3639 | 3639 | $n = count($dataSet); |
3640 | 3640 | |
3641 | - return 1 - self::NORMSDIST((self::AVERAGE($dataSet) - $m0)/($sigma/SQRT($n))); |
|
3641 | + return 1 - self::NORMSDIST((self::AVERAGE($dataSet) - $m0) / ($sigma / SQRT($n))); |
|
3642 | 3642 | } // function ZTEST() |
3643 | 3643 | |
3644 | 3644 | } // class PHPExcel_Calculation_Statistical |
@@ -396,8 +396,9 @@ discard block |
||
396 | 396 | if ($y <= $lg_frtbig) { |
397 | 397 | $res = $lg_c[6]; |
398 | 398 | $ysq = $y * $y; |
399 | - for ($i = 0; $i < 6; ++$i) |
|
400 | - $res = $res / $ysq + $lg_c[$i]; |
|
399 | + for ($i = 0; $i < 6; ++$i) { |
|
400 | + $res = $res / $ysq + $lg_c[$i]; |
|
401 | + } |
|
401 | 402 | } |
402 | 403 | $res /= $y; |
403 | 404 | $corr = log($y); |
@@ -440,7 +441,9 @@ discard block |
||
440 | 441 | // Private implementation of the Gamma function |
441 | 442 | // |
442 | 443 | private static function _gamma($data) { |
443 | - if ($data == 0.0) return 0; |
|
444 | + if ($data == 0.0) { |
|
445 | + return 0; |
|
446 | + } |
|
444 | 447 | |
445 | 448 | static $p0 = 1.000000000190015; |
446 | 449 | static $p = array ( 1 => 76.18009172947146, |
@@ -1957,7 +1960,9 @@ discard block |
||
1957 | 1960 | public static function LINEST($yValues,$xValues=null,$const=True,$stats=False) { |
1958 | 1961 | $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
1959 | 1962 | $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
1960 | - if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
1963 | + if (is_null($xValues)) { |
|
1964 | + $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
1965 | + } |
|
1961 | 1966 | |
1962 | 1967 | if (!self::_checkTrendArrays($yValues,$xValues)) { |
1963 | 1968 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -2010,7 +2015,9 @@ discard block |
||
2010 | 2015 | public static function LOGEST($yValues,$xValues=null,$const=True,$stats=False) { |
2011 | 2016 | $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); |
2012 | 2017 | $stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats); |
2013 | - if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
2018 | + if (is_null($xValues)) { |
|
2019 | + $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues))); |
|
2020 | + } |
|
2014 | 2021 | |
2015 | 2022 | if (!self::_checkTrendArrays($yValues,$xValues)) { |
2016 | 2023 | return PHPExcel_Calculation_Functions::VALUE(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * CHARACTER |
70 | 70 | * |
71 | 71 | * @param string $character Value |
72 | - * @return int |
|
72 | + * @return string |
|
73 | 73 | */ |
74 | 74 | public static function CHARACTER($character) { |
75 | 75 | $character = PHPExcel_Calculation_Functions::flattenSingleValue($character); |
@@ -89,7 +89,6 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * TRIMNONPRINTABLE |
91 | 91 | * |
92 | - * @param mixed $value Value to check |
|
93 | 92 | * @return string |
94 | 93 | */ |
95 | 94 | public static function TRIMNONPRINTABLE($stringValue = '') { |
@@ -113,7 +112,6 @@ discard block |
||
113 | 112 | /** |
114 | 113 | * TRIMSPACES |
115 | 114 | * |
116 | - * @param mixed $value Value to check |
|
117 | 115 | * @return string |
118 | 116 | */ |
119 | 117 | public static function TRIMSPACES($stringValue = '') { |
@@ -133,7 +131,7 @@ discard block |
||
133 | 131 | /** |
134 | 132 | * ASCIICODE |
135 | 133 | * |
136 | - * @param string $character Value |
|
134 | + * @param string $characters Value |
|
137 | 135 | * @return int |
138 | 136 | */ |
139 | 137 | public static function ASCIICODE($characters) { |
@@ -192,7 +190,7 @@ discard block |
||
192 | 190 | * This function converts a number to text using currency format, with the decimals rounded to the specified place. |
193 | 191 | * The format used is $#,##0.00_);($#,##0.00).. |
194 | 192 | * |
195 | - * @param float $value The value to format |
|
193 | + * @param integer $value The value to format |
|
196 | 194 | * @param int $decimals The number of digits to display to the right of the decimal point. |
197 | 195 | * If decimals is negative, number is rounded to the left of the decimal point. |
198 | 196 | * If you omit decimals, it is assumed to be 2 |
@@ -291,7 +289,7 @@ discard block |
||
291 | 289 | * FIXEDFORMAT |
292 | 290 | * |
293 | 291 | * @param mixed $value Value to check |
294 | - * @return boolean |
|
292 | + * @return string |
|
295 | 293 | */ |
296 | 294 | public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) { |
297 | 295 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
@@ -401,8 +399,7 @@ discard block |
||
401 | 399 | * STRINGLENGTH |
402 | 400 | * |
403 | 401 | * @param string $value Value |
404 | - * @param int $chars Number of characters |
|
405 | - * @return string |
|
402 | + * @return integer |
|
406 | 403 | */ |
407 | 404 | public static function STRINGLENGTH($value = '') { |
408 | 405 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
@@ -491,7 +488,6 @@ discard block |
||
491 | 488 | /** |
492 | 489 | * REPLACE |
493 | 490 | * |
494 | - * @param string $value Value |
|
495 | 491 | * @param int $start Start character |
496 | 492 | * @param int $chars Number of characters |
497 | 493 | * @return string |
@@ -559,8 +555,7 @@ discard block |
||
559 | 555 | /** |
560 | 556 | * RETURNSTRING |
561 | 557 | * |
562 | - * @param mixed $value Value to check |
|
563 | - * @return boolean |
|
558 | + * @return string|null |
|
564 | 559 | */ |
565 | 560 | public static function RETURNSTRING($testValue = '') { |
566 | 561 | $testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue); |
@@ -576,7 +571,7 @@ discard block |
||
576 | 571 | * TEXTFORMAT |
577 | 572 | * |
578 | 573 | * @param mixed $value Value to check |
579 | - * @return boolean |
|
574 | + * @return string |
|
580 | 575 | */ |
581 | 576 | public static function TEXTFORMAT($value,$format) { |
582 | 577 | $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | private static $_invalidChars = Null; |
49 | 49 | |
50 | 50 | private static function _uniord($c) { |
51 | - if (ord($c{0}) >=0 && ord($c{0}) <= 127) |
|
51 | + if (ord($c{0}) >= 0 && ord($c{0}) <= 127) |
|
52 | 52 | return ord($c{0}); |
53 | 53 | if (ord($c{0}) >= 192 && ord($c{0}) <= 223) |
54 | - return (ord($c{0})-192)*64 + (ord($c{1})-128); |
|
54 | + return (ord($c{0}) - 192) * 64 + (ord($c{1}) - 128); |
|
55 | 55 | if (ord($c{0}) >= 224 && ord($c{0}) <= 239) |
56 | - return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128); |
|
56 | + return (ord($c{0}) - 224) * 4096 + (ord($c{1}) - 128) * 64 + (ord($c{2}) - 128); |
|
57 | 57 | if (ord($c{0}) >= 240 && ord($c{0}) <= 247) |
58 | - return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128); |
|
58 | + return (ord($c{0}) - 240) * 262144 + (ord($c{1}) - 128) * 4096 + (ord($c{2}) - 128) * 64 + (ord($c{3}) - 128); |
|
59 | 59 | if (ord($c{0}) >= 248 && ord($c{0}) <= 251) |
60 | - return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128); |
|
60 | + return (ord($c{0}) - 248) * 16777216 + (ord($c{1}) - 128) * 262144 + (ord($c{2}) - 128) * 4096 + (ord($c{3}) - 128) * 64 + (ord($c{4}) - 128); |
|
61 | 61 | if (ord($c{0}) >= 252 && ord($c{0}) <= 253) |
62 | - return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128); |
|
62 | + return (ord($c{0}) - 252) * 1073741824 + (ord($c{1}) - 128) * 16777216 + (ord($c{2}) - 128) * 262144 + (ord($c{3}) - 128) * 4096 + (ord($c{4}) - 128) * 64 + (ord($c{5}) - 128); |
|
63 | 63 | if (ord($c{0}) >= 254 && ord($c{0}) <= 255) //error |
64 | 64 | return PHPExcel_Calculation_Functions::VALUE(); |
65 | 65 | return 0; |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @return int |
73 | 73 | */ |
74 | 74 | public static function CHARACTER($character) { |
75 | - $character = PHPExcel_Calculation_Functions::flattenSingleValue($character); |
|
75 | + $character = PHPExcel_Calculation_Functions::flattenSingleValue($character); |
|
76 | 76 | |
77 | - if ((!is_numeric($character)) || ($character < 0)) { |
|
77 | + if (( ! is_numeric($character)) || ($character < 0)) { |
|
78 | 78 | return PHPExcel_Calculation_Functions::VALUE(); |
79 | 79 | } |
80 | 80 | |
@@ -93,18 +93,18 @@ discard block |
||
93 | 93 | * @return string |
94 | 94 | */ |
95 | 95 | public static function TRIMNONPRINTABLE($stringValue = '') { |
96 | - $stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); |
|
96 | + $stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); |
|
97 | 97 | |
98 | 98 | if (is_bool($stringValue)) { |
99 | 99 | return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); |
100 | 100 | } |
101 | 101 | |
102 | 102 | if (self::$_invalidChars == Null) { |
103 | - self::$_invalidChars = range(chr(0),chr(31)); |
|
103 | + self::$_invalidChars = range(chr(0), chr(31)); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | if (is_string($stringValue) || is_numeric($stringValue)) { |
107 | - return str_replace(self::$_invalidChars,'',trim($stringValue,"\x00..\x1F")); |
|
107 | + return str_replace(self::$_invalidChars, '', trim($stringValue, "\x00..\x1F")); |
|
108 | 108 | } |
109 | 109 | return NULL; |
110 | 110 | } // function TRIMNONPRINTABLE() |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | * @return string |
118 | 118 | */ |
119 | 119 | public static function TRIMSPACES($stringValue = '') { |
120 | - $stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); |
|
120 | + $stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); |
|
121 | 121 | |
122 | 122 | if (is_bool($stringValue)) { |
123 | 123 | return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); |
124 | 124 | } |
125 | 125 | |
126 | 126 | if (is_string($stringValue) || is_numeric($stringValue)) { |
127 | - return trim(preg_replace('/ +/',' ',trim($stringValue,' '))); |
|
127 | + return trim(preg_replace('/ +/', ' ', trim($stringValue, ' '))); |
|
128 | 128 | } |
129 | 129 | return NULL; |
130 | 130 | } // function TRIMSPACES() |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public static function ASCIICODE($characters) { |
140 | 140 | if (($characters === NULL) || ($characters === '')) |
141 | 141 | return PHPExcel_Calculation_Functions::VALUE(); |
142 | - $characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters); |
|
142 | + $characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters); |
|
143 | 143 | if (is_bool($characters)) { |
144 | 144 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
145 | 145 | $characters = (int) $characters; |
@@ -199,24 +199,24 @@ discard block |
||
199 | 199 | * @return string |
200 | 200 | */ |
201 | 201 | public static function DOLLAR($value = 0, $decimals = 2) { |
202 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
203 | - $decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals); |
|
202 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
203 | + $decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals); |
|
204 | 204 | |
205 | 205 | // Validate parameters |
206 | - if (!is_numeric($value) || !is_numeric($decimals)) { |
|
206 | + if ( ! is_numeric($value) || ! is_numeric($decimals)) { |
|
207 | 207 | return PHPExcel_Calculation_Functions::NaN(); |
208 | 208 | } |
209 | 209 | $decimals = floor($decimals); |
210 | 210 | |
211 | 211 | if ($decimals > 0) { |
212 | - return money_format('%.'.$decimals.'n',$value); |
|
212 | + return money_format('%.'.$decimals.'n', $value); |
|
213 | 213 | } else { |
214 | - $round = pow(10,abs($decimals)); |
|
215 | - if ($value < 0) { $round = 0-$round; } |
|
216 | - $value = PHPExcel_Calculation_MathTrig::MROUND($value,$round); |
|
214 | + $round = pow(10, abs($decimals)); |
|
215 | + if ($value < 0) { $round = 0 - $round; } |
|
216 | + $value = PHPExcel_Calculation_MathTrig::MROUND($value, $round); |
|
217 | 217 | // The implementation of money_format used if the standard PHP function is not available can't handle decimal places of 0, |
218 | 218 | // so we display to 1 dp and chop off that character and the decimal separator using substr |
219 | - return substr(money_format('%.1n',$value),0,-2); |
|
219 | + return substr(money_format('%.1n', $value), 0, -2); |
|
220 | 220 | } |
221 | 221 | } // function DOLLAR() |
222 | 222 | |
@@ -229,19 +229,19 @@ discard block |
||
229 | 229 | * @param int $offset Offset within $haystack |
230 | 230 | * @return string |
231 | 231 | */ |
232 | - public static function SEARCHSENSITIVE($needle,$haystack,$offset=1) { |
|
232 | + public static function SEARCHSENSITIVE($needle, $haystack, $offset = 1) { |
|
233 | 233 | $needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle); |
234 | - $haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack); |
|
234 | + $haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack); |
|
235 | 235 | $offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset); |
236 | 236 | |
237 | - if (!is_bool($needle)) { |
|
237 | + if ( ! is_bool($needle)) { |
|
238 | 238 | if (is_bool($haystack)) { |
239 | 239 | $haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); |
240 | 240 | } |
241 | 241 | |
242 | 242 | if (($offset > 0) && (strlen($haystack) > $offset)) { |
243 | 243 | if (function_exists('mb_strpos')) { |
244 | - $pos = mb_strpos($haystack, $needle, --$offset,'UTF-8'); |
|
244 | + $pos = mb_strpos($haystack, $needle, --$offset, 'UTF-8'); |
|
245 | 245 | } else { |
246 | 246 | $pos = strpos($haystack, $needle, --$offset); |
247 | 247 | } |
@@ -262,19 +262,19 @@ discard block |
||
262 | 262 | * @param int $offset Offset within $haystack |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public static function SEARCHINSENSITIVE($needle,$haystack,$offset=1) { |
|
265 | + public static function SEARCHINSENSITIVE($needle, $haystack, $offset = 1) { |
|
266 | 266 | $needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle); |
267 | - $haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack); |
|
267 | + $haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack); |
|
268 | 268 | $offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset); |
269 | 269 | |
270 | - if (!is_bool($needle)) { |
|
270 | + if ( ! is_bool($needle)) { |
|
271 | 271 | if (is_bool($haystack)) { |
272 | 272 | $haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); |
273 | 273 | } |
274 | 274 | |
275 | 275 | if (($offset > 0) && (strlen($haystack) > $offset)) { |
276 | 276 | if (function_exists('mb_stripos')) { |
277 | - $pos = mb_stripos($haystack, $needle, --$offset,'UTF-8'); |
|
277 | + $pos = mb_stripos($haystack, $needle, --$offset, 'UTF-8'); |
|
278 | 278 | } else { |
279 | 279 | $pos = stripos($haystack, $needle, --$offset); |
280 | 280 | } |
@@ -294,20 +294,20 @@ discard block |
||
294 | 294 | * @return boolean |
295 | 295 | */ |
296 | 296 | public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) { |
297 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
298 | - $decimals = PHPExcel_Calculation_Functions::flattenSingleValue($decimals); |
|
299 | - $no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas); |
|
297 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
298 | + $decimals = PHPExcel_Calculation_Functions::flattenSingleValue($decimals); |
|
299 | + $no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas); |
|
300 | 300 | |
301 | 301 | // Validate parameters |
302 | - if (!is_numeric($value) || !is_numeric($decimals)) { |
|
302 | + if ( ! is_numeric($value) || ! is_numeric($decimals)) { |
|
303 | 303 | return PHPExcel_Calculation_Functions::NaN(); |
304 | 304 | } |
305 | 305 | $decimals = floor($decimals); |
306 | 306 | |
307 | - $valueResult = round($value,$decimals); |
|
307 | + $valueResult = round($value, $decimals); |
|
308 | 308 | if ($decimals < 0) { $decimals = 0; } |
309 | - if (!$no_commas) { |
|
310 | - $valueResult = number_format($valueResult,$decimals); |
|
309 | + if ( ! $no_commas) { |
|
310 | + $valueResult = number_format($valueResult, $decimals); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | return (string) $valueResult; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @return string |
429 | 429 | */ |
430 | 430 | public static function LOWERCASE($mixedCaseString) { |
431 | - $mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); |
|
431 | + $mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); |
|
432 | 432 | |
433 | 433 | if (is_bool($mixedCaseString)) { |
434 | 434 | $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * @return string |
452 | 452 | */ |
453 | 453 | public static function UPPERCASE($mixedCaseString) { |
454 | - $mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); |
|
454 | + $mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); |
|
455 | 455 | |
456 | 456 | if (is_bool($mixedCaseString)) { |
457 | 457 | $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * @return string |
475 | 475 | */ |
476 | 476 | public static function PROPERCASE($mixedCaseString) { |
477 | - $mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); |
|
477 | + $mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString); |
|
478 | 478 | |
479 | 479 | if (is_bool($mixedCaseString)) { |
480 | 480 | $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | $chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars); |
503 | 503 | $newText = PHPExcel_Calculation_Functions::flattenSingleValue($newText); |
504 | 504 | |
505 | - $left = self::LEFT($oldText,$start-1); |
|
506 | - $right = self::RIGHT($oldText,self::STRINGLENGTH($oldText)-($start+$chars)+1); |
|
505 | + $left = self::LEFT($oldText, $start - 1); |
|
506 | + $right = self::RIGHT($oldText, self::STRINGLENGTH($oldText) - ($start + $chars) + 1); |
|
507 | 507 | |
508 | 508 | return $left.$newText.$right; |
509 | 509 | } // function REPLACE() |
@@ -519,24 +519,24 @@ discard block |
||
519 | 519 | * @return string |
520 | 520 | */ |
521 | 521 | public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) { |
522 | - $text = PHPExcel_Calculation_Functions::flattenSingleValue($text); |
|
522 | + $text = PHPExcel_Calculation_Functions::flattenSingleValue($text); |
|
523 | 523 | $fromText = PHPExcel_Calculation_Functions::flattenSingleValue($fromText); |
524 | - $toText = PHPExcel_Calculation_Functions::flattenSingleValue($toText); |
|
524 | + $toText = PHPExcel_Calculation_Functions::flattenSingleValue($toText); |
|
525 | 525 | $instance = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance)); |
526 | 526 | |
527 | 527 | if ($instance == 0) { |
528 | - if(function_exists('mb_str_replace')) { |
|
529 | - return mb_str_replace($fromText,$toText,$text); |
|
528 | + if (function_exists('mb_str_replace')) { |
|
529 | + return mb_str_replace($fromText, $toText, $text); |
|
530 | 530 | } else { |
531 | - return str_replace($fromText,$toText,$text); |
|
531 | + return str_replace($fromText, $toText, $text); |
|
532 | 532 | } |
533 | 533 | } else { |
534 | 534 | $pos = -1; |
535 | - while($instance > 0) { |
|
535 | + while ($instance > 0) { |
|
536 | 536 | if (function_exists('mb_strpos')) { |
537 | - $pos = mb_strpos($text, $fromText, $pos+1, 'UTF-8'); |
|
537 | + $pos = mb_strpos($text, $fromText, $pos + 1, 'UTF-8'); |
|
538 | 538 | } else { |
539 | - $pos = strpos($text, $fromText, $pos+1); |
|
539 | + $pos = strpos($text, $fromText, $pos + 1); |
|
540 | 540 | } |
541 | 541 | if ($pos === false) { |
542 | 542 | break; |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | } |
546 | 546 | if ($pos !== false) { |
547 | 547 | if (function_exists('mb_strlen')) { |
548 | - return self::REPLACE($text,++$pos,mb_strlen($fromText, 'UTF-8'),$toText); |
|
548 | + return self::REPLACE($text, ++$pos, mb_strlen($fromText, 'UTF-8'), $toText); |
|
549 | 549 | } else { |
550 | - return self::REPLACE($text,++$pos,strlen($fromText),$toText); |
|
550 | + return self::REPLACE($text, ++$pos, strlen($fromText), $toText); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @return boolean |
564 | 564 | */ |
565 | 565 | public static function RETURNSTRING($testValue = '') { |
566 | - $testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue); |
|
566 | + $testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue); |
|
567 | 567 | |
568 | 568 | if (is_string($testValue)) { |
569 | 569 | return $testValue; |
@@ -578,15 +578,15 @@ discard block |
||
578 | 578 | * @param mixed $value Value to check |
579 | 579 | * @return boolean |
580 | 580 | */ |
581 | - public static function TEXTFORMAT($value,$format) { |
|
582 | - $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
581 | + public static function TEXTFORMAT($value, $format) { |
|
582 | + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); |
|
583 | 583 | $format = PHPExcel_Calculation_Functions::flattenSingleValue($format); |
584 | 584 | |
585 | - if ((is_string($value)) && (!is_numeric($value)) && PHPExcel_Shared_Date::isDateTimeFormatCode($format)) { |
|
585 | + if ((is_string($value)) && ( ! is_numeric($value)) && PHPExcel_Shared_Date::isDateTimeFormatCode($format)) { |
|
586 | 586 | $value = PHPExcel_Calculation_DateTime::DATEVALUE($value); |
587 | 587 | } |
588 | 588 | |
589 | - return (string) PHPExcel_Style_NumberFormat::toFormattedString($value,$format); |
|
589 | + return (string) PHPExcel_Style_NumberFormat::toFormattedString($value, $format); |
|
590 | 590 | } // function TEXTFORMAT() |
591 | 591 | |
592 | 592 | } // class PHPExcel_Calculation_TextData |
@@ -48,20 +48,28 @@ discard block |
||
48 | 48 | private static $_invalidChars = Null; |
49 | 49 | |
50 | 50 | private static function _uniord($c) { |
51 | - if (ord($c{0}) >=0 && ord($c{0}) <= 127) |
|
52 | - return ord($c{0}); |
|
53 | - if (ord($c{0}) >= 192 && ord($c{0}) <= 223) |
|
54 | - return (ord($c{0})-192)*64 + (ord($c{1})-128); |
|
55 | - if (ord($c{0}) >= 224 && ord($c{0}) <= 239) |
|
56 | - return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128); |
|
57 | - if (ord($c{0}) >= 240 && ord($c{0}) <= 247) |
|
58 | - return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128); |
|
59 | - if (ord($c{0}) >= 248 && ord($c{0}) <= 251) |
|
60 | - return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128); |
|
61 | - if (ord($c{0}) >= 252 && ord($c{0}) <= 253) |
|
62 | - return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128); |
|
63 | - if (ord($c{0}) >= 254 && ord($c{0}) <= 255) //error |
|
51 | + if (ord($c{0}) >=0 && ord($c{0}) <= 127) { |
|
52 | + return ord($c{0}); |
|
53 | + } |
|
54 | + if (ord($c{0}) >= 192 && ord($c{0}) <= 223) { |
|
55 | + return (ord($c{0})-192)*64 + (ord($c{1})-128); |
|
56 | + } |
|
57 | + if (ord($c{0}) >= 224 && ord($c{0}) <= 239) { |
|
58 | + return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128); |
|
59 | + } |
|
60 | + if (ord($c{0}) >= 240 && ord($c{0}) <= 247) { |
|
61 | + return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128); |
|
62 | + } |
|
63 | + if (ord($c{0}) >= 248 && ord($c{0}) <= 251) { |
|
64 | + return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128); |
|
65 | + } |
|
66 | + if (ord($c{0}) >= 252 && ord($c{0}) <= 253) { |
|
67 | + return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128); |
|
68 | + } |
|
69 | + if (ord($c{0}) >= 254 && ord($c{0}) <= 255) { |
|
70 | + //error |
|
64 | 71 | return PHPExcel_Calculation_Functions::VALUE(); |
72 | + } |
|
65 | 73 | return 0; |
66 | 74 | } // function _uniord() |
67 | 75 | |
@@ -137,8 +145,9 @@ discard block |
||
137 | 145 | * @return int |
138 | 146 | */ |
139 | 147 | public static function ASCIICODE($characters) { |
140 | - if (($characters === NULL) || ($characters === '')) |
|
141 | - return PHPExcel_Calculation_Functions::VALUE(); |
|
148 | + if (($characters === NULL) || ($characters === '')) { |
|
149 | + return PHPExcel_Calculation_Functions::VALUE(); |
|
150 | + } |
|
142 | 151 | $characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters); |
143 | 152 | if (is_bool($characters)) { |
144 | 153 | if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * Send notification to the cache controller |
104 | 104 | * |
105 | - * @return void |
|
105 | + * @return PHPExcel_Cell |
|
106 | 106 | **/ |
107 | 107 | public function notifyCacheController() { |
108 | 108 | $this->_parent->getCellCacheController()->updateCacheData($this); |
@@ -113,6 +113,9 @@ discard block |
||
113 | 113 | $this->_parent = null; |
114 | 114 | } |
115 | 115 | |
116 | + /** |
|
117 | + * @param PHPExcel_Worksheet|null $parent |
|
118 | + */ |
|
116 | 119 | public function attach($parent) { |
117 | 120 | $this->_parent = $parent; |
118 | 121 | } |
@@ -498,7 +501,7 @@ discard block |
||
498 | 501 | * Coordinate from string |
499 | 502 | * |
500 | 503 | * @param string $pCoordinateString |
501 | - * @return array Array containing column and row (indexes 0 and 1) |
|
504 | + * @return string[] Array containing column and row (indexes 0 and 1) |
|
502 | 505 | * @throws Exception |
503 | 506 | */ |
504 | 507 | public static function coordinateFromString($pCoordinateString = 'A1') |
@@ -652,7 +655,7 @@ discard block |
||
652 | 655 | * Calculate range boundaries |
653 | 656 | * |
654 | 657 | * @param string $pRange Cell range (e.g. A1:A1) |
655 | - * @return array Range boundaries (staring Column, starting Row, Final Column, Final Row) |
|
658 | + * @return integer Range boundaries (staring Column, starting Row, Final Column, Final Row) |
|
656 | 659 | */ |
657 | 660 | public static function getRangeBoundaries($pRange = 'A1:A1') |
658 | 661 | { |
@@ -203,8 +203,8 @@ |
||
203 | 203 | public function getFormattedValue() |
204 | 204 | { |
205 | 205 | return (string) PHPExcel_Style_NumberFormat::toFormattedString( $this->getCalculatedValue(), |
206 | - $this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())->getNumberFormat()->getFormatCode() |
|
207 | - ); |
|
206 | + $this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())->getNumberFormat()->getFormatCode() |
|
207 | + ); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; |
147 | 147 | $this->_dataType = $pDataType; |
148 | 148 | } else { |
149 | - if (!self::getValueBinder()->bindValue($this, $pValue)) { |
|
149 | + if ( ! self::getValueBinder()->bindValue($this, $pValue)) { |
|
150 | 150 | throw new Exception("Value could not be bound to cell."); |
151 | 151 | } |
152 | 152 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function getCoordinate() |
184 | 184 | { |
185 | - return $this->_column . $this->_row; |
|
185 | + return $this->_column.$this->_row; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function getFormattedValue() |
204 | 204 | { |
205 | - return (string) PHPExcel_Style_NumberFormat::toFormattedString( $this->getCalculatedValue(), |
|
205 | + return (string) PHPExcel_Style_NumberFormat::toFormattedString($this->getCalculatedValue(), |
|
206 | 206 | $this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())->getNumberFormat()->getFormatCode() |
207 | 207 | ); |
208 | 208 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function setValue($pValue = null) |
219 | 219 | { |
220 | - if (!self::getValueBinder()->bindValue($this, $pValue)) { |
|
220 | + if ( ! self::getValueBinder()->bindValue($this, $pValue)) { |
|
221 | 221 | throw new Exception("Value could not be bound to cell."); |
222 | 222 | } |
223 | 223 | return $this; |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | break; |
245 | 245 | |
246 | 246 | case PHPExcel_Cell_DataType::TYPE_NUMERIC: |
247 | - $this->_value = (float)$pValue; |
|
247 | + $this->_value = (float) $pValue; |
|
248 | 248 | break; |
249 | 249 | |
250 | 250 | case PHPExcel_Cell_DataType::TYPE_FORMULA: |
251 | - $this->_value = (string)$pValue; |
|
251 | + $this->_value = (string) $pValue; |
|
252 | 252 | break; |
253 | 253 | |
254 | 254 | case PHPExcel_Cell_DataType::TYPE_BOOL: |
255 | - $this->_value = (bool)$pValue; |
|
255 | + $this->_value = (bool) $pValue; |
|
256 | 256 | break; |
257 | 257 | |
258 | 258 | case PHPExcel_Cell_DataType::TYPE_ERROR: |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | break; |
261 | 261 | |
262 | 262 | default: |
263 | - throw new Exception('Invalid datatype: ' . $pDataType); |
|
263 | + throw new Exception('Invalid datatype: '.$pDataType); |
|
264 | 264 | break; |
265 | 265 | } |
266 | 266 | |
@@ -275,15 +275,15 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return mixed |
277 | 277 | */ |
278 | - public function getCalculatedValue($resetLog=true) |
|
278 | + public function getCalculatedValue($resetLog = true) |
|
279 | 279 | { |
280 | 280 | // echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().'<br />'; |
281 | 281 | if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) { |
282 | 282 | try { |
283 | 283 | // echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value<br />'; |
284 | - $result = PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog); |
|
284 | + $result = PHPExcel_Calculation::getInstance()->calculateCellValue($this, $resetLog); |
|
285 | 285 | // echo $this->getCoordinate().' calculation result is '.$result.'<br />'; |
286 | - } catch ( Exception $ex ) { |
|
286 | + } catch (Exception $ex) { |
|
287 | 287 | if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) { |
288 | 288 | // echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'<br />'; |
289 | 289 | return $this->_calculatedValue; // Fallback for calculations referencing external files. |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | */ |
368 | 368 | public function hasDataValidation() |
369 | 369 | { |
370 | - if (!isset($this->_parent)) { |
|
370 | + if ( ! isset($this->_parent)) { |
|
371 | 371 | throw new Exception('Cannot check for data validation when cell is not bound to a worksheet'); |
372 | 372 | } |
373 | 373 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public function getDataValidation() |
383 | 383 | { |
384 | - if (!isset($this->_parent)) { |
|
384 | + if ( ! isset($this->_parent)) { |
|
385 | 385 | throw new Exception('Cannot get data validation for cell that is not bound to a worksheet'); |
386 | 386 | } |
387 | 387 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null) |
399 | 399 | { |
400 | - if (!isset($this->_parent)) { |
|
400 | + if ( ! isset($this->_parent)) { |
|
401 | 401 | throw new Exception('Cannot set data validation for cell that is not bound to a worksheet'); |
402 | 402 | } |
403 | 403 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | */ |
414 | 414 | public function hasHyperlink() |
415 | 415 | { |
416 | - if (!isset($this->_parent)) { |
|
416 | + if ( ! isset($this->_parent)) { |
|
417 | 417 | throw new Exception('Cannot check for hyperlink when cell is not bound to a worksheet'); |
418 | 418 | } |
419 | 419 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | */ |
429 | 429 | public function getHyperlink() |
430 | 430 | { |
431 | - if (!isset($this->_parent)) { |
|
431 | + if ( ! isset($this->_parent)) { |
|
432 | 432 | throw new Exception('Cannot get hyperlink for cell that is not bound to a worksheet'); |
433 | 433 | } |
434 | 434 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | */ |
445 | 445 | public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = null) |
446 | 446 | { |
447 | - if (!isset($this->_parent)) { |
|
447 | + if ( ! isset($this->_parent)) { |
|
448 | 448 | throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet'); |
449 | 449 | } |
450 | 450 | |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | */ |
483 | 483 | public function isInRange($pRange = 'A1:A1') |
484 | 484 | { |
485 | - list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange); |
|
485 | + list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange); |
|
486 | 486 | |
487 | 487 | // Translate properties |
488 | - $myColumn = PHPExcel_Cell::columnIndexFromString($this->getColumn()); |
|
489 | - $myRow = $this->getRow(); |
|
488 | + $myColumn = PHPExcel_Cell::columnIndexFromString($this->getColumn()); |
|
489 | + $myRow = $this->getRow(); |
|
490 | 490 | |
491 | 491 | // Verify if cell is in range |
492 | 492 | return (($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) && |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | public static function coordinateFromString($pCoordinateString = 'A1') |
505 | 505 | { |
506 | 506 | if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) { |
507 | - return array($matches[1],$matches[2]); |
|
508 | - } elseif ((strpos($pCoordinateString,':') !== false) || (strpos($pCoordinateString,',') !== false)) { |
|
507 | + return array($matches[1], $matches[2]); |
|
508 | + } elseif ((strpos($pCoordinateString, ':') !== false) || (strpos($pCoordinateString, ',') !== false)) { |
|
509 | 509 | throw new Exception('Cell coordinate string can not be a range of cells.'); |
510 | 510 | } elseif ($pCoordinateString == '') { |
511 | 511 | throw new Exception('Cell coordinate can not be zero-length string.'); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | */ |
524 | 524 | public static function absoluteReference($pCoordinateString = 'A1') |
525 | 525 | { |
526 | - if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) { |
|
526 | + if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) { |
|
527 | 527 | // Create absolute coordinate |
528 | 528 | if (ctype_digit($pCoordinateString)) { |
529 | 529 | return '$'.$pCoordinateString; |
@@ -545,20 +545,20 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public static function absoluteCoordinate($pCoordinateString = 'A1') |
547 | 547 | { |
548 | - if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) { |
|
548 | + if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) { |
|
549 | 549 | // Create absolute coordinate |
550 | 550 | $worksheet = ''; |
551 | - $cellAddress = explode('!',$pCoordinateString); |
|
551 | + $cellAddress = explode('!', $pCoordinateString); |
|
552 | 552 | if (count($cellAddress) == 2) { |
553 | - list($worksheet,$pCoordinateString) = $cellAddress; |
|
553 | + list($worksheet, $pCoordinateString) = $cellAddress; |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | list($column, $row) = PHPExcel_Cell::coordinateFromString($pCoordinateString); |
557 | - if ($column[0] == '$') $column = substr($column,1); |
|
558 | - if ($row[0] == '$') $row = substr($row,1); |
|
557 | + if ($column[0] == '$') $column = substr($column, 1); |
|
558 | + if ($row[0] == '$') $row = substr($row, 1); |
|
559 | 559 | if ($worksheet > '') |
560 | 560 | $worksheet .= '!'; |
561 | - return $worksheet . '$' . $column . '$' . $row; |
|
561 | + return $worksheet.'$'.$column.'$'.$row; |
|
562 | 562 | } else { |
563 | 563 | throw new Exception("Coordinate string should not be a cell range."); |
564 | 564 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | public static function buildRange($pRange) |
591 | 591 | { |
592 | 592 | // Verify range |
593 | - if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) { |
|
593 | + if ( ! is_array($pRange) || empty($pRange) || ! is_array($pRange[0])) { |
|
594 | 594 | throw new Exception('Range does not contain any information.'); |
595 | 595 | } |
596 | 596 | |
@@ -625,11 +625,11 @@ discard block |
||
625 | 625 | |
626 | 626 | // Calculate range outer borders |
627 | 627 | $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); |
628 | - $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB); |
|
628 | + $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB); |
|
629 | 629 | |
630 | 630 | // Translate column into index |
631 | - $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]); |
|
632 | - $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]); |
|
631 | + $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]); |
|
632 | + $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]); |
|
633 | 633 | |
634 | 634 | return array($rangeStart, $rangeEnd); |
635 | 635 | } |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | public static function rangeDimension($pRange = 'A1:A1') |
644 | 644 | { |
645 | 645 | // Calculate range outer borders |
646 | - list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange); |
|
646 | + list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange); |
|
647 | 647 | |
648 | - return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) ); |
|
648 | + return array(($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1)); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | list($rangeA, $rangeB) = explode(':', $pRange); |
667 | 667 | } |
668 | 668 | |
669 | - return array( self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)); |
|
669 | + return array(self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -699,18 +699,18 @@ discard block |
||
699 | 699 | // We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString |
700 | 700 | // for improved performance |
701 | 701 | if (isset($pString{0})) { |
702 | - if (!isset($pString{1})) { |
|
702 | + if ( ! isset($pString{1})) { |
|
703 | 703 | $_indexCache[$pString] = $_columnLookup[$pString]; |
704 | 704 | return $_indexCache[$pString]; |
705 | - } elseif(!isset($pString{2})) { |
|
705 | + } elseif ( ! isset($pString{2})) { |
|
706 | 706 | $_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}]; |
707 | 707 | return $_indexCache[$pString]; |
708 | - } elseif(!isset($pString{3})) { |
|
708 | + } elseif ( ! isset($pString{3})) { |
|
709 | 709 | $_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}]; |
710 | 710 | return $_indexCache[$pString]; |
711 | 711 | } |
712 | 712 | } |
713 | - throw new Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty") . "."); |
|
713 | + throw new Exception("Column string index can not be ".((isset($pString{0})) ? "longer than 3 characters" : "empty")."."); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -726,16 +726,16 @@ discard block |
||
726 | 726 | // though it's additional memory overhead |
727 | 727 | static $_indexCache = array(); |
728 | 728 | |
729 | - if (!isset($_indexCache[$pColumnIndex])) { |
|
729 | + if ( ! isset($_indexCache[$pColumnIndex])) { |
|
730 | 730 | // Determine column string |
731 | 731 | if ($pColumnIndex < 26) { |
732 | 732 | $_indexCache[$pColumnIndex] = chr(65 + $pColumnIndex); |
733 | 733 | } elseif ($pColumnIndex < 702) { |
734 | - $_indexCache[$pColumnIndex] = chr(64 + ($pColumnIndex / 26)) . |
|
734 | + $_indexCache[$pColumnIndex] = chr(64 + ($pColumnIndex / 26)). |
|
735 | 735 | chr(65 + $pColumnIndex % 26); |
736 | 736 | } else { |
737 | - $_indexCache[$pColumnIndex] = chr(64 + (($pColumnIndex - 26) / 676)) . |
|
738 | - chr(65 + ((($pColumnIndex - 26) % 676) / 26)) . |
|
737 | + $_indexCache[$pColumnIndex] = chr(64 + (($pColumnIndex - 26) / 676)). |
|
738 | + chr(65 + ((($pColumnIndex - 26) % 676) / 26)). |
|
739 | 739 | chr(65 + $pColumnIndex % 26); |
740 | 740 | } |
741 | 741 | } |
@@ -756,24 +756,24 @@ discard block |
||
756 | 756 | $cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange))); |
757 | 757 | foreach ($cellBlocks as $cellBlock) { |
758 | 758 | // Single cell? |
759 | - if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) { |
|
759 | + if (strpos($cellBlock, ':') === false && strpos($cellBlock, ',') === false) { |
|
760 | 760 | $returnValue[] = $cellBlock; |
761 | 761 | continue; |
762 | 762 | } |
763 | 763 | |
764 | 764 | // Range... |
765 | 765 | $ranges = PHPExcel_Cell::splitRange($cellBlock); |
766 | - foreach($ranges as $range) { |
|
766 | + foreach ($ranges as $range) { |
|
767 | 767 | // Single cell? |
768 | - if (!isset($range[1])) { |
|
768 | + if ( ! isset($range[1])) { |
|
769 | 769 | $returnValue[] = $range[0]; |
770 | 770 | continue; |
771 | 771 | } |
772 | 772 | |
773 | 773 | // Range... |
774 | - list($rangeStart, $rangeEnd) = $range; |
|
775 | - list($startCol, $startRow) = sscanf($rangeStart,'%[A-Z]%d'); |
|
776 | - list($endCol, $endRow) = sscanf($rangeEnd,'%[A-Z]%d'); |
|
774 | + list($rangeStart, $rangeEnd) = $range; |
|
775 | + list($startCol, $startRow) = sscanf($rangeStart, '%[A-Z]%d'); |
|
776 | + list($endCol, $endRow) = sscanf($rangeEnd, '%[A-Z]%d'); |
|
777 | 777 | $endCol++; |
778 | 778 | |
779 | 779 | // Current data |
@@ -142,8 +142,9 @@ discard block |
||
142 | 142 | |
143 | 143 | // Set datatype? |
144 | 144 | if ($pDataType !== null) { |
145 | - if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) |
|
146 | - $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; |
|
145 | + if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) { |
|
146 | + $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; |
|
147 | + } |
|
147 | 148 | $this->_dataType = $pDataType; |
148 | 149 | } else { |
149 | 150 | if (!self::getValueBinder()->bindValue($this, $pValue)) { |
@@ -352,8 +353,9 @@ discard block |
||
352 | 353 | */ |
353 | 354 | public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING) |
354 | 355 | { |
355 | - if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) |
|
356 | - $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; |
|
356 | + if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) { |
|
357 | + $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; |
|
358 | + } |
|
357 | 359 | |
358 | 360 | $this->_dataType = $pDataType; |
359 | 361 | |
@@ -554,10 +556,15 @@ discard block |
||
554 | 556 | } |
555 | 557 | |
556 | 558 | list($column, $row) = PHPExcel_Cell::coordinateFromString($pCoordinateString); |
557 | - if ($column[0] == '$') $column = substr($column,1); |
|
558 | - if ($row[0] == '$') $row = substr($row,1); |
|
559 | - if ($worksheet > '') |
|
560 | - $worksheet .= '!'; |
|
559 | + if ($column[0] == '$') { |
|
560 | + $column = substr($column,1); |
|
561 | + } |
|
562 | + if ($row[0] == '$') { |
|
563 | + $row = substr($row,1); |
|
564 | + } |
|
565 | + if ($worksheet > '') { |
|
566 | + $worksheet .= '!'; |
|
567 | + } |
|
561 | 568 | return $worksheet . '$' . $column . '$' . $row; |
562 | 569 | } else { |
563 | 570 | throw new Exception("Coordinate string should not be a cell range."); |
@@ -683,8 +690,9 @@ discard block |
||
683 | 690 | // though it's additional memory overhead |
684 | 691 | static $_indexCache = array(); |
685 | 692 | |
686 | - if (isset($_indexCache[$pString])) |
|
687 | - return $_indexCache[$pString]; |
|
693 | + if (isset($_indexCache[$pString])) { |
|
694 | + return $_indexCache[$pString]; |
|
695 | + } |
|
688 | 696 | |
689 | 697 | // It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord() |
690 | 698 | // and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant |