@@ -35,27 +35,27 @@ |
||
35 | 35 | */ |
36 | 36 | class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { |
37 | 37 | |
38 | - /** |
|
39 | - * Add or Update a cell in cache identified by coordinate address |
|
40 | - * |
|
41 | - * @param string $pCoord Coordinate address of the cell to update |
|
42 | - * @param PHPExcel_Cell $cell Cell to update |
|
38 | + /** |
|
39 | + * Add or Update a cell in cache identified by coordinate address |
|
40 | + * |
|
41 | + * @param string $pCoord Coordinate address of the cell to update |
|
42 | + * @param PHPExcel_Cell $cell Cell to update |
|
43 | 43 | * @return void |
44 | - * @throws Exception |
|
45 | - */ |
|
44 | + * @throws Exception |
|
45 | + */ |
|
46 | 46 | public function addCacheData($pCoord, PHPExcel_Cell $cell) { |
47 | 47 | $this->_cellCache[$pCoord] = $cell; |
48 | 48 | return $cell; |
49 | 49 | } // function addCacheData() |
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Get cell at a specific coordinate |
|
54 | - * |
|
55 | - * @param string $pCoord Coordinate of the cell |
|
56 | - * @throws Exception |
|
57 | - * @return PHPExcel_Cell Cell that was found, or null if not found |
|
58 | - */ |
|
52 | + /** |
|
53 | + * Get cell at a specific coordinate |
|
54 | + * |
|
55 | + * @param string $pCoord Coordinate of the cell |
|
56 | + * @throws Exception |
|
57 | + * @return PHPExcel_Cell Cell that was found, or null if not found |
|
58 | + */ |
|
59 | 59 | public function getCacheData($pCoord) { |
60 | 60 | // Check if the entry that has been requested actually exists |
61 | 61 | if (!isset($this->_cellCache[$pCoord])) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function getCacheData($pCoord) { |
60 | 60 | // Check if the entry that has been requested actually exists |
61 | - if (!isset($this->_cellCache[$pCoord])) { |
|
61 | + if ( ! isset($this->_cellCache[$pCoord])) { |
|
62 | 62 | // Return null if requested entry doesn't exist in cache |
63 | 63 | return null; |
64 | 64 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | parent::copyCellCollection($parent); |
79 | 79 | |
80 | 80 | $newCollection = array(); |
81 | - foreach($this->_cellCache as $k => &$cell) { |
|
81 | + foreach ($this->_cellCache as $k => &$cell) { |
|
82 | 82 | $newCollection[$k] = clone $cell; |
83 | 83 | $newCollection[$k]->attach($parent); |
84 | 84 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function unsetWorksheetCells() { |
96 | 96 | // Because cells are all stored as intact objects in memory, we need to detach each one from the parent |
97 | - foreach($this->_cellCache as $k => &$cell) { |
|
97 | + foreach ($this->_cellCache as $k => &$cell) { |
|
98 | 98 | $cell->detach(); |
99 | 99 | $this->_cellCache[$k] = null; |
100 | 100 | } |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { |
37 | 37 | |
38 | - /** |
|
39 | - * Store cell data in cache for the current cell object if it's "dirty", |
|
40 | - * and the 'nullify' the current cell object |
|
41 | - * |
|
38 | + /** |
|
39 | + * Store cell data in cache for the current cell object if it's "dirty", |
|
40 | + * and the 'nullify' the current cell object |
|
41 | + * |
|
42 | 42 | * @return void |
43 | - * @throws Exception |
|
44 | - */ |
|
43 | + * @throws Exception |
|
44 | + */ |
|
45 | 45 | private function _storeData() { |
46 | 46 | if ($this->_currentCellIsDirty) { |
47 | 47 | $this->_currentObject->detach(); |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | } // function _storeData() |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Add or Update a cell in cache identified by coordinate address |
|
58 | - * |
|
59 | - * @param string $pCoord Coordinate address of the cell to update |
|
60 | - * @param PHPExcel_Cell $cell Cell to update |
|
56 | + /** |
|
57 | + * Add or Update a cell in cache identified by coordinate address |
|
58 | + * |
|
59 | + * @param string $pCoord Coordinate address of the cell to update |
|
60 | + * @param PHPExcel_Cell $cell Cell to update |
|
61 | 61 | * @return void |
62 | - * @throws Exception |
|
63 | - */ |
|
62 | + * @throws Exception |
|
63 | + */ |
|
64 | 64 | public function addCacheData($pCoord, PHPExcel_Cell $cell) { |
65 | 65 | if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { |
66 | 66 | $this->_storeData(); |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | } // function addCacheData() |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * Get cell at a specific coordinate |
|
79 | - * |
|
80 | - * @param string $pCoord Coordinate of the cell |
|
81 | - * @throws Exception |
|
82 | - * @return PHPExcel_Cell Cell that was found, or null if not found |
|
83 | - */ |
|
77 | + /** |
|
78 | + * Get cell at a specific coordinate |
|
79 | + * |
|
80 | + * @param string $pCoord Coordinate of the cell |
|
81 | + * @throws Exception |
|
82 | + * @return PHPExcel_Cell Cell that was found, or null if not found |
|
83 | + */ |
|
84 | 84 | public function getCacheData($pCoord) { |
85 | 85 | if ($pCoord === $this->_currentObjectID) { |
86 | 86 | return $this->_currentObject; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $this->_storeData(); |
89 | 89 | |
90 | 90 | // Check if the entry that has been requested actually exists |
91 | - if (!isset($this->_cellCache[$pCoord])) { |
|
91 | + if ( ! isset($this->_cellCache[$pCoord])) { |
|
92 | 92 | // Return null if requested entry doesn't exist in cache |
93 | 93 | return null; |
94 | 94 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @return void |
111 | 111 | */ |
112 | 112 | public function unsetWorksheetCells() { |
113 | - if(!is_null($this->_currentObject)) { |
|
113 | + if ( ! is_null($this->_currentObject)) { |
|
114 | 114 | $this->_currentObject->detach(); |
115 | 115 | $this->_currentObject = $this->_currentObjectID = null; |
116 | 116 | } |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { |
37 | 37 | |
38 | - /** |
|
39 | - * Store cell data in cache for the current cell object if it's "dirty", |
|
40 | - * and the 'nullify' the current cell object |
|
41 | - * |
|
38 | + /** |
|
39 | + * Store cell data in cache for the current cell object if it's "dirty", |
|
40 | + * and the 'nullify' the current cell object |
|
41 | + * |
|
42 | 42 | * @return void |
43 | - * @throws Exception |
|
44 | - */ |
|
43 | + * @throws Exception |
|
44 | + */ |
|
45 | 45 | private function _storeData() { |
46 | 46 | if ($this->_currentCellIsDirty) { |
47 | 47 | $this->_currentObject->detach(); |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | } // function _storeData() |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Add or Update a cell in cache identified by coordinate address |
|
58 | - * |
|
59 | - * @param string $pCoord Coordinate address of the cell to update |
|
60 | - * @param PHPExcel_Cell $cell Cell to update |
|
56 | + /** |
|
57 | + * Add or Update a cell in cache identified by coordinate address |
|
58 | + * |
|
59 | + * @param string $pCoord Coordinate address of the cell to update |
|
60 | + * @param PHPExcel_Cell $cell Cell to update |
|
61 | 61 | * @return void |
62 | - * @throws Exception |
|
63 | - */ |
|
62 | + * @throws Exception |
|
63 | + */ |
|
64 | 64 | public function addCacheData($pCoord, PHPExcel_Cell $cell) { |
65 | 65 | if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { |
66 | 66 | $this->_storeData(); |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | } // function addCacheData() |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * Get cell at a specific coordinate |
|
79 | - * |
|
80 | - * @param string $pCoord Coordinate of the cell |
|
81 | - * @throws Exception |
|
82 | - * @return PHPExcel_Cell Cell that was found, or null if not found |
|
83 | - */ |
|
77 | + /** |
|
78 | + * Get cell at a specific coordinate |
|
79 | + * |
|
80 | + * @param string $pCoord Coordinate of the cell |
|
81 | + * @throws Exception |
|
82 | + * @return PHPExcel_Cell Cell that was found, or null if not found |
|
83 | + */ |
|
84 | 84 | public function getCacheData($pCoord) { |
85 | 85 | if ($pCoord === $this->_currentObjectID) { |
86 | 86 | return $this->_currentObject; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $this->_storeData(); |
89 | 89 | |
90 | 90 | // Check if the entry that has been requested actually exists |
91 | - if (!isset($this->_cellCache[$pCoord])) { |
|
91 | + if ( ! isset($this->_cellCache[$pCoord])) { |
|
92 | 92 | // Return null if requested entry doesn't exist in cache |
93 | 93 | return null; |
94 | 94 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @return void |
111 | 111 | */ |
112 | 112 | public function unsetWorksheetCells() { |
113 | - if(!is_null($this->_currentObject)) { |
|
113 | + if ( ! is_null($this->_currentObject)) { |
|
114 | 114 | $this->_currentObject->detach(); |
115 | 115 | $this->_currentObject = $this->_currentObjectID = null; |
116 | 116 | } |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | private $_DBHandle = null; |
51 | 51 | |
52 | - /** |
|
53 | - * Store cell data in cache for the current cell object if it's "dirty", |
|
54 | - * and the 'nullify' the current cell object |
|
55 | - * |
|
52 | + /** |
|
53 | + * Store cell data in cache for the current cell object if it's "dirty", |
|
54 | + * and the 'nullify' the current cell object |
|
55 | + * |
|
56 | 56 | * @return void |
57 | - * @throws Exception |
|
58 | - */ |
|
57 | + * @throws Exception |
|
58 | + */ |
|
59 | 59 | private function _storeData() { |
60 | 60 | if ($this->_currentCellIsDirty) { |
61 | 61 | $this->_currentObject->detach(); |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | } // function _storeData() |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Add or Update a cell in cache identified by coordinate address |
|
73 | - * |
|
74 | - * @param string $pCoord Coordinate address of the cell to update |
|
75 | - * @param PHPExcel_Cell $cell Cell to update |
|
71 | + /** |
|
72 | + * Add or Update a cell in cache identified by coordinate address |
|
73 | + * |
|
74 | + * @param string $pCoord Coordinate address of the cell to update |
|
75 | + * @param PHPExcel_Cell $cell Cell to update |
|
76 | 76 | * @return void |
77 | - * @throws Exception |
|
78 | - */ |
|
77 | + * @throws Exception |
|
78 | + */ |
|
79 | 79 | public function addCacheData($pCoord, PHPExcel_Cell $cell) { |
80 | 80 | if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { |
81 | 81 | $this->_storeData(); |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | } // function addCacheData() |
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Get cell at a specific coordinate |
|
94 | - * |
|
95 | - * @param string $pCoord Coordinate of the cell |
|
96 | - * @throws Exception |
|
97 | - * @return PHPExcel_Cell Cell that was found, or null if not found |
|
98 | - */ |
|
92 | + /** |
|
93 | + * Get cell at a specific coordinate |
|
94 | + * |
|
95 | + * @param string $pCoord Coordinate of the cell |
|
96 | + * @throws Exception |
|
97 | + * @return PHPExcel_Cell Cell that was found, or null if not found |
|
98 | + */ |
|
99 | 99 | public function getCacheData($pCoord) { |
100 | 100 | if ($pCoord === $this->_currentObjectID) { |
101 | 101 | return $this->_currentObject; |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | } // function isDataSet() |
149 | 149 | |
150 | 150 | |
151 | - /** |
|
152 | - * Delete a cell in cache identified by coordinate address |
|
153 | - * |
|
154 | - * @param string $pCoord Coordinate address of the cell to delete |
|
155 | - * @throws Exception |
|
156 | - */ |
|
151 | + /** |
|
152 | + * Delete a cell in cache identified by coordinate address |
|
153 | + * |
|
154 | + * @param string $pCoord Coordinate address of the cell to delete |
|
155 | + * @throws Exception |
|
156 | + */ |
|
157 | 157 | public function deleteCacheData($pCoord) { |
158 | 158 | if ($pCoord === $this->_currentObjectID) { |
159 | 159 | $this->_currentObject->detach(); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if ($this->_currentCellIsDirty) { |
61 | 61 | $this->_currentObject->detach(); |
62 | 62 | |
63 | - if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) |
|
63 | + if ( ! $this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) |
|
64 | 64 | throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
65 | 65 | $this->_currentCellIsDirty = false; |
66 | 66 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $this->_storeData(); |
104 | 104 | |
105 | 105 | $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; |
106 | - $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC); |
|
106 | + $cellResultSet = $this->_DBHandle->query($query, SQLITE_ASSOC); |
|
107 | 107 | if ($cellResultSet === false) { |
108 | 108 | throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
109 | 109 | } elseif ($cellResultSet->numRows() == 0) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | // Check if the requested entry exists in the cache |
139 | 139 | $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; |
140 | - $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC); |
|
140 | + $cellResultSet = $this->_DBHandle->query($query, SQLITE_ASSOC); |
|
141 | 141 | if ($cellResultSet === false) { |
142 | 142 | throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
143 | 143 | } elseif ($cellResultSet->numRows() == 0) { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | // Check if the requested entry exists in the cache |
164 | 164 | $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; |
165 | - if (!$this->_DBHandle->queryExec($query)) |
|
165 | + if ( ! $this->_DBHandle->queryExec($query)) |
|
166 | 166 | throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
167 | 167 | |
168 | 168 | $this->_currentCellIsDirty = false; |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function getCellList() { |
178 | 178 | $query = "SELECT id FROM kvp_".$this->_TableName; |
179 | - $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC); |
|
179 | + $cellIdsResult = $this->_DBHandle->unbufferedQuery($query, SQLITE_ASSOC); |
|
180 | 180 | if ($cellIdsResult === false) |
181 | 181 | throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
182 | 182 | |
183 | 183 | $cellKeys = array(); |
184 | - foreach($cellIdsResult as $row) { |
|
184 | + foreach ($cellIdsResult as $row) { |
|
185 | 185 | $cellKeys[] = $row['id']; |
186 | 186 | } |
187 | 187 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function copyCellCollection(PHPExcel_Worksheet $parent) { |
199 | 199 | // Get a new id for the new table name |
200 | - $tableName = str_replace('.','_',$this->_getUniqueID()); |
|
201 | - if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) |
|
200 | + $tableName = str_replace('.', '_', $this->_getUniqueID()); |
|
201 | + if ( ! $this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) |
|
202 | 202 | AS SELECT * FROM kvp_'.$this->_TableName)) |
203 | 203 | throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
204 | 204 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @return void |
214 | 214 | */ |
215 | 215 | public function unsetWorksheetCells() { |
216 | - if(!is_null($this->_currentObject)) { |
|
216 | + if ( ! is_null($this->_currentObject)) { |
|
217 | 217 | $this->_currentObject->detach(); |
218 | 218 | $this->_currentObject = $this->_currentObjectID = null; |
219 | 219 | } |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | public function __construct(PHPExcel_Worksheet $parent) { |
234 | 234 | parent::__construct($parent); |
235 | 235 | if (is_null($this->_DBHandle)) { |
236 | - $this->_TableName = str_replace('.','_',$this->_getUniqueID()); |
|
236 | + $this->_TableName = str_replace('.', '_', $this->_getUniqueID()); |
|
237 | 237 | $_DBName = ':memory:'; |
238 | 238 | |
239 | 239 | $this->_DBHandle = new SQLiteDatabase($_DBName); |
240 | 240 | if ($this->_DBHandle === false) |
241 | 241 | throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
242 | - if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) |
|
242 | + if ( ! $this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) |
|
243 | 243 | throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
244 | 244 | } |
245 | 245 | } // function __construct() |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @return boolean |
261 | 261 | */ |
262 | 262 | public static function cacheMethodIsAvailable() { |
263 | - if (!function_exists('sqlite_open')) { |
|
263 | + if ( ! function_exists('sqlite_open')) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 |
@@ -60,8 +60,9 @@ discard block |
||
60 | 60 | if ($this->_currentCellIsDirty) { |
61 | 61 | $this->_currentObject->detach(); |
62 | 62 | |
63 | - if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) |
|
64 | - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
63 | + if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) { |
|
64 | + throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
65 | + } |
|
65 | 66 | $this->_currentCellIsDirty = false; |
66 | 67 | } |
67 | 68 | $this->_currentObjectID = $this->_currentObject = null; |
@@ -162,8 +163,9 @@ discard block |
||
162 | 163 | |
163 | 164 | // Check if the requested entry exists in the cache |
164 | 165 | $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; |
165 | - if (!$this->_DBHandle->queryExec($query)) |
|
166 | - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
166 | + if (!$this->_DBHandle->queryExec($query)) { |
|
167 | + throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
168 | + } |
|
167 | 169 | |
168 | 170 | $this->_currentCellIsDirty = false; |
169 | 171 | } // function deleteCacheData() |
@@ -177,8 +179,9 @@ discard block |
||
177 | 179 | public function getCellList() { |
178 | 180 | $query = "SELECT id FROM kvp_".$this->_TableName; |
179 | 181 | $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC); |
180 | - if ($cellIdsResult === false) |
|
181 | - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
182 | + if ($cellIdsResult === false) { |
|
183 | + throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
184 | + } |
|
182 | 185 | |
183 | 186 | $cellKeys = array(); |
184 | 187 | foreach($cellIdsResult as $row) { |
@@ -199,8 +202,9 @@ discard block |
||
199 | 202 | // Get a new id for the new table name |
200 | 203 | $tableName = str_replace('.','_',$this->_getUniqueID()); |
201 | 204 | if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) |
202 | - AS SELECT * FROM kvp_'.$this->_TableName)) |
|
203 | - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
205 | + AS SELECT * FROM kvp_'.$this->_TableName)) { |
|
206 | + throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
207 | + } |
|
204 | 208 | |
205 | 209 | // Copy the existing cell cache file |
206 | 210 | $this->_TableName = $tableName; |
@@ -237,10 +241,12 @@ discard block |
||
237 | 241 | $_DBName = ':memory:'; |
238 | 242 | |
239 | 243 | $this->_DBHandle = new SQLiteDatabase($_DBName); |
240 | - if ($this->_DBHandle === false) |
|
241 | - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
242 | - if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) |
|
243 | - throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
244 | + if ($this->_DBHandle === false) { |
|
245 | + throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
246 | + } |
|
247 | + if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) { |
|
248 | + throw new Exception(sqlite_error_string($this->_DBHandle->lastError())); |
|
249 | + } |
|
244 | 250 | } |
245 | 251 | } // function __construct() |
246 | 252 |
@@ -77,7 +77,7 @@ |
||
77 | 77 | * |
78 | 78 | * @param string $pCoord Coordinate address of the cell to update |
79 | 79 | * @param PHPExcel_Cell $cell Cell to update |
80 | - * @return void |
|
80 | + * @return PHPExcel_Cell |
|
81 | 81 | * @throws Exception |
82 | 82 | */ |
83 | 83 | public function addCacheData($pCoord, PHPExcel_Cell $cell) { |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | private $_DBHandle = null; |
51 | 51 | |
52 | - /** |
|
53 | - * Store cell data in cache for the current cell object if it's "dirty", |
|
54 | - * and the 'nullify' the current cell object |
|
55 | - * |
|
52 | + /** |
|
53 | + * Store cell data in cache for the current cell object if it's "dirty", |
|
54 | + * and the 'nullify' the current cell object |
|
55 | + * |
|
56 | 56 | * @return void |
57 | - * @throws Exception |
|
58 | - */ |
|
57 | + * @throws Exception |
|
58 | + */ |
|
59 | 59 | private function _storeData() { |
60 | 60 | if ($this->_currentCellIsDirty) { |
61 | 61 | $this->_currentObject->detach(); |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | } // function _storeData() |
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * Add or Update a cell in cache identified by coordinate address |
|
77 | - * |
|
78 | - * @param string $pCoord Coordinate address of the cell to update |
|
79 | - * @param PHPExcel_Cell $cell Cell to update |
|
75 | + /** |
|
76 | + * Add or Update a cell in cache identified by coordinate address |
|
77 | + * |
|
78 | + * @param string $pCoord Coordinate address of the cell to update |
|
79 | + * @param PHPExcel_Cell $cell Cell to update |
|
80 | 80 | * @return void |
81 | - * @throws Exception |
|
82 | - */ |
|
81 | + * @throws Exception |
|
82 | + */ |
|
83 | 83 | public function addCacheData($pCoord, PHPExcel_Cell $cell) { |
84 | 84 | if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { |
85 | 85 | $this->_storeData(); |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | } // function addCacheData() |
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * Get cell at a specific coordinate |
|
98 | - * |
|
99 | - * @param string $pCoord Coordinate of the cell |
|
100 | - * @throws Exception |
|
101 | - * @return PHPExcel_Cell Cell that was found, or null if not found |
|
102 | - */ |
|
96 | + /** |
|
97 | + * Get cell at a specific coordinate |
|
98 | + * |
|
99 | + * @param string $pCoord Coordinate of the cell |
|
100 | + * @throws Exception |
|
101 | + * @return PHPExcel_Cell Cell that was found, or null if not found |
|
102 | + */ |
|
103 | 103 | public function getCacheData($pCoord) { |
104 | 104 | if ($pCoord === $this->_currentObjectID) { |
105 | 105 | return $this->_currentObject; |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | } // function isDataSet() |
152 | 152 | |
153 | 153 | |
154 | - /** |
|
155 | - * Delete a cell in cache identified by coordinate address |
|
156 | - * |
|
157 | - * @param string $pCoord Coordinate address of the cell to delete |
|
158 | - * @throws Exception |
|
159 | - */ |
|
154 | + /** |
|
155 | + * Delete a cell in cache identified by coordinate address |
|
156 | + * |
|
157 | + * @param string $pCoord Coordinate address of the cell to delete |
|
158 | + * @throws Exception |
|
159 | + */ |
|
160 | 160 | public function deleteCacheData($pCoord) { |
161 | 161 | if ($pCoord === $this->_currentObjectID) { |
162 | 162 | $this->_currentObject->detach(); |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | $this->_currentObject->detach(); |
62 | 62 | |
63 | 63 | $query = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)"); |
64 | - $query->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT); |
|
65 | - $query->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB); |
|
64 | + $query->bindValue('id', $this->_currentObjectID, SQLITE3_TEXT); |
|
65 | + $query->bindValue('data', serialize($this->_currentObject), SQLITE3_BLOB); |
|
66 | 66 | $result = $query->execute(); |
67 | 67 | if ($result === false) |
68 | 68 | throw new Exception($this->_DBHandle->lastErrorMsg()); |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function copyCellCollection(PHPExcel_Worksheet $parent) { |
203 | 203 | // Get a new id for the new table name |
204 | - $tableName = str_replace('.','_',$this->_getUniqueID()); |
|
205 | - if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) |
|
204 | + $tableName = str_replace('.', '_', $this->_getUniqueID()); |
|
205 | + if ( ! $this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) |
|
206 | 206 | AS SELECT * FROM kvp_'.$this->_TableName)) |
207 | 207 | throw new Exception($this->_DBHandle->lastErrorMsg()); |
208 | 208 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @return void |
218 | 218 | */ |
219 | 219 | public function unsetWorksheetCells() { |
220 | - if(!is_null($this->_currentObject)) { |
|
220 | + if ( ! is_null($this->_currentObject)) { |
|
221 | 221 | $this->_currentObject->detach(); |
222 | 222 | $this->_currentObject = $this->_currentObjectID = null; |
223 | 223 | } |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | public function __construct(PHPExcel_Worksheet $parent) { |
238 | 238 | parent::__construct($parent); |
239 | 239 | if (is_null($this->_DBHandle)) { |
240 | - $this->_TableName = str_replace('.','_',$this->_getUniqueID()); |
|
240 | + $this->_TableName = str_replace('.', '_', $this->_getUniqueID()); |
|
241 | 241 | $_DBName = ':memory:'; |
242 | 242 | |
243 | 243 | $this->_DBHandle = new SQLite3($_DBName); |
244 | 244 | if ($this->_DBHandle === false) |
245 | 245 | throw new Exception($this->_DBHandle->lastErrorMsg()); |
246 | - if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) |
|
246 | + if ( ! $this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) |
|
247 | 247 | throw new Exception($this->_DBHandle->lastErrorMsg()); |
248 | 248 | } |
249 | 249 | } // function __construct() |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * Destroy this cell collection |
254 | 254 | */ |
255 | 255 | public function __destruct() { |
256 | - if (!is_null($this->_DBHandle)) { |
|
256 | + if ( ! is_null($this->_DBHandle)) { |
|
257 | 257 | $this->_DBHandle->close(); |
258 | 258 | } |
259 | 259 | $this->_DBHandle = null; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return boolean |
268 | 268 | */ |
269 | 269 | public static function cacheMethodIsAvailable() { |
270 | - if (!class_exists('SQLite3')) { |
|
270 | + if ( ! class_exists('SQLite3')) { |
|
271 | 271 | return false; |
272 | 272 | } |
273 | 273 |
@@ -64,8 +64,9 @@ discard block |
||
64 | 64 | $query->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT); |
65 | 65 | $query->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB); |
66 | 66 | $result = $query->execute(); |
67 | - if ($result === false) |
|
68 | - throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
67 | + if ($result === false) { |
|
68 | + throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
69 | + } |
|
69 | 70 | $this->_currentCellIsDirty = false; |
70 | 71 | } |
71 | 72 | $this->_currentObjectID = $this->_currentObject = null; |
@@ -166,8 +167,9 @@ discard block |
||
166 | 167 | // Check if the requested entry exists in the cache |
167 | 168 | $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; |
168 | 169 | $result = $this->_DBHandle->exec($query); |
169 | - if ($result === false) |
|
170 | - throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
170 | + if ($result === false) { |
|
171 | + throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
172 | + } |
|
171 | 173 | |
172 | 174 | $this->_currentCellIsDirty = false; |
173 | 175 | } // function deleteCacheData() |
@@ -181,8 +183,9 @@ discard block |
||
181 | 183 | public function getCellList() { |
182 | 184 | $query = "SELECT id FROM kvp_".$this->_TableName; |
183 | 185 | $cellIdsResult = $this->_DBHandle->query($query); |
184 | - if ($cellIdsResult === false) |
|
185 | - throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
186 | + if ($cellIdsResult === false) { |
|
187 | + throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
188 | + } |
|
186 | 189 | |
187 | 190 | $cellKeys = array(); |
188 | 191 | while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) { |
@@ -203,8 +206,9 @@ discard block |
||
203 | 206 | // Get a new id for the new table name |
204 | 207 | $tableName = str_replace('.','_',$this->_getUniqueID()); |
205 | 208 | if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) |
206 | - AS SELECT * FROM kvp_'.$this->_TableName)) |
|
207 | - throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
209 | + AS SELECT * FROM kvp_'.$this->_TableName)) { |
|
210 | + throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
211 | + } |
|
208 | 212 | |
209 | 213 | // Copy the existing cell cache file |
210 | 214 | $this->_TableName = $tableName; |
@@ -241,10 +245,12 @@ discard block |
||
241 | 245 | $_DBName = ':memory:'; |
242 | 246 | |
243 | 247 | $this->_DBHandle = new SQLite3($_DBName); |
244 | - if ($this->_DBHandle === false) |
|
245 | - throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
246 | - if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) |
|
247 | - throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
248 | + if ($this->_DBHandle === false) { |
|
249 | + throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
250 | + } |
|
251 | + if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) { |
|
252 | + throw new Exception($this->_DBHandle->lastErrorMsg()); |
|
253 | + } |
|
248 | 254 | } |
249 | 255 | } // function __construct() |
250 | 256 |
@@ -77,7 +77,7 @@ |
||
77 | 77 | * |
78 | 78 | * @param string $pCoord Coordinate address of the cell to update |
79 | 79 | * @param PHPExcel_Cell $cell Cell to update |
80 | - * @return void |
|
80 | + * @return PHPExcel_Cell |
|
81 | 81 | * @throws Exception |
82 | 82 | */ |
83 | 83 | public function addCacheData($pCoord, PHPExcel_Cell $cell) { |
@@ -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 | |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | * @return string|NULL |
65 | 65 | * |
66 | 66 | */ |
67 | - private static function __fieldExtract($database,$field) { |
|
67 | + private static function __fieldExtract($database, $field) { |
|
68 | 68 | $field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field)); |
69 | - $fieldNames = array_map('strtoupper',array_shift($database)); |
|
69 | + $fieldNames = array_map('strtoupper', array_shift($database)); |
|
70 | 70 | |
71 | 71 | if (is_numeric($field)) { |
72 | 72 | $keys = array_keys($fieldNames); |
73 | - return $keys[$field-1]; |
|
73 | + return $keys[$field - 1]; |
|
74 | 74 | } |
75 | - $key = array_search($field,$fieldNames); |
|
75 | + $key = array_search($field, $fieldNames); |
|
76 | 76 | return ($key) ? $key : NULL; |
77 | 77 | } |
78 | 78 | |
@@ -95,53 +95,53 @@ discard block |
||
95 | 95 | * @return array of mixed |
96 | 96 | * |
97 | 97 | */ |
98 | - private static function __filter($database,$criteria) { |
|
98 | + private static function __filter($database, $criteria) { |
|
99 | 99 | $fieldNames = array_shift($database); |
100 | 100 | $criteriaNames = array_shift($criteria); |
101 | 101 | |
102 | 102 | // Convert the criteria into a set of AND/OR conditions with [:placeholders] |
103 | 103 | $testConditions = $testValues = array(); |
104 | 104 | $testConditionsCount = 0; |
105 | - foreach($criteriaNames as $key => $criteriaName) { |
|
105 | + foreach ($criteriaNames as $key => $criteriaName) { |
|
106 | 106 | $testCondition = array(); |
107 | 107 | $testConditionCount = 0; |
108 | - foreach($criteria as $row => $criterion) { |
|
108 | + foreach ($criteria as $row => $criterion) { |
|
109 | 109 | if ($criterion[$key] > '') { |
110 | 110 | $testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::_ifCondition($criterion[$key]); |
111 | 111 | $testConditionCount++; |
112 | 112 | } |
113 | 113 | } |
114 | 114 | if ($testConditionCount > 1) { |
115 | - $testConditions[] = 'OR('.implode(',',$testCondition).')'; |
|
115 | + $testConditions[] = 'OR('.implode(',', $testCondition).')'; |
|
116 | 116 | $testConditionsCount++; |
117 | - } elseif($testConditionCount == 1) { |
|
117 | + } elseif ($testConditionCount == 1) { |
|
118 | 118 | $testConditions[] = $testCondition[0]; |
119 | 119 | $testConditionsCount++; |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | 123 | if ($testConditionsCount > 1) { |
124 | - $testConditionSet = 'AND('.implode(',',$testConditions).')'; |
|
125 | - } elseif($testConditionsCount == 1) { |
|
124 | + $testConditionSet = 'AND('.implode(',', $testConditions).')'; |
|
125 | + } elseif ($testConditionsCount == 1) { |
|
126 | 126 | $testConditionSet = $testConditions[0]; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Loop through each row of the database |
130 | - foreach($database as $dataRow => $dataValues) { |
|
130 | + foreach ($database as $dataRow => $dataValues) { |
|
131 | 131 | // Substitute actual values from the database row for our [:placeholders] |
132 | 132 | $testConditionList = $testConditionSet; |
133 | - foreach($criteriaNames as $key => $criteriaName) { |
|
134 | - $k = array_search($criteriaName,$fieldNames); |
|
133 | + foreach ($criteriaNames as $key => $criteriaName) { |
|
134 | + $k = array_search($criteriaName, $fieldNames); |
|
135 | 135 | if (isset($dataValues[$k])) { |
136 | 136 | $dataValue = $dataValues[$k]; |
137 | 137 | $dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue; |
138 | - $testConditionList = str_replace('[:'.$criteriaName.']',$dataValue,$testConditionList); |
|
138 | + $testConditionList = str_replace('[:'.$criteriaName.']', $dataValue, $testConditionList); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | // evaluate the criteria against the row data |
142 | 142 | $result = PHPExcel_Calculation::getInstance()->_calculateFormulaValue('='.$testConditionList); |
143 | 143 | // If the row failed to meet the criteria, remove it from the database |
144 | - if (!$result) { |
|
144 | + if ( ! $result) { |
|
145 | 145 | unset($database[$dataRow]); |
146 | 146 | } |
147 | 147 | } |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | * @return float |
178 | 178 | * |
179 | 179 | */ |
180 | - public static function DAVERAGE($database,$field,$criteria) { |
|
181 | - $field = self::__fieldExtract($database,$field); |
|
180 | + public static function DAVERAGE($database, $field, $criteria) { |
|
181 | + $field = self::__fieldExtract($database, $field); |
|
182 | 182 | if (is_null($field)) { |
183 | 183 | return NULL; |
184 | 184 | } |
185 | 185 | // reduce the database to a set of rows that match all the criteria |
186 | - $database = self::__filter($database,$criteria); |
|
186 | + $database = self::__filter($database, $criteria); |
|
187 | 187 | // extract an array of values for the requested column |
188 | 188 | $colData = array(); |
189 | - foreach($database as $row) { |
|
189 | + foreach ($database as $row) { |
|
190 | 190 | $colData[] = $row[$field]; |
191 | 191 | } |
192 | 192 | |
@@ -229,17 +229,17 @@ discard block |
||
229 | 229 | * database that match the criteria. |
230 | 230 | * |
231 | 231 | */ |
232 | - public static function DCOUNT($database,$field,$criteria) { |
|
233 | - $field = self::__fieldExtract($database,$field); |
|
232 | + public static function DCOUNT($database, $field, $criteria) { |
|
233 | + $field = self::__fieldExtract($database, $field); |
|
234 | 234 | if (is_null($field)) { |
235 | 235 | return NULL; |
236 | 236 | } |
237 | 237 | |
238 | 238 | // reduce the database to a set of rows that match all the criteria |
239 | - $database = self::__filter($database,$criteria); |
|
239 | + $database = self::__filter($database, $criteria); |
|
240 | 240 | // extract an array of values for the requested column |
241 | 241 | $colData = array(); |
242 | - foreach($database as $row) { |
|
242 | + foreach ($database as $row) { |
|
243 | 243 | $colData[] = $row[$field]; |
244 | 244 | } |
245 | 245 | |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | * database that match the criteria. |
279 | 279 | * |
280 | 280 | */ |
281 | - public static function DCOUNTA($database,$field,$criteria) { |
|
282 | - $field = self::__fieldExtract($database,$field); |
|
281 | + public static function DCOUNTA($database, $field, $criteria) { |
|
282 | + $field = self::__fieldExtract($database, $field); |
|
283 | 283 | if (is_null($field)) { |
284 | 284 | return NULL; |
285 | 285 | } |
286 | 286 | |
287 | 287 | // reduce the database to a set of rows that match all the criteria |
288 | - $database = self::__filter($database,$criteria); |
|
288 | + $database = self::__filter($database, $criteria); |
|
289 | 289 | // extract an array of values for the requested column |
290 | 290 | $colData = array(); |
291 | - foreach($database as $row) { |
|
291 | + foreach ($database as $row) { |
|
292 | 292 | $colData[] = $row[$field]; |
293 | 293 | } |
294 | 294 | |
@@ -325,17 +325,17 @@ discard block |
||
325 | 325 | * @return mixed |
326 | 326 | * |
327 | 327 | */ |
328 | - public static function DGET($database,$field,$criteria) { |
|
329 | - $field = self::__fieldExtract($database,$field); |
|
328 | + public static function DGET($database, $field, $criteria) { |
|
329 | + $field = self::__fieldExtract($database, $field); |
|
330 | 330 | if (is_null($field)) { |
331 | 331 | return NULL; |
332 | 332 | } |
333 | 333 | |
334 | 334 | // reduce the database to a set of rows that match all the criteria |
335 | - $database = self::__filter($database,$criteria); |
|
335 | + $database = self::__filter($database, $criteria); |
|
336 | 336 | // extract an array of values for the requested column |
337 | 337 | $colData = array(); |
338 | - foreach($database as $row) { |
|
338 | + foreach ($database as $row) { |
|
339 | 339 | $colData[] = $row[$field]; |
340 | 340 | } |
341 | 341 | |
@@ -376,17 +376,17 @@ discard block |
||
376 | 376 | * @return float |
377 | 377 | * |
378 | 378 | */ |
379 | - public static function DMAX($database,$field,$criteria) { |
|
380 | - $field = self::__fieldExtract($database,$field); |
|
379 | + public static function DMAX($database, $field, $criteria) { |
|
380 | + $field = self::__fieldExtract($database, $field); |
|
381 | 381 | if (is_null($field)) { |
382 | 382 | return NULL; |
383 | 383 | } |
384 | 384 | |
385 | 385 | // reduce the database to a set of rows that match all the criteria |
386 | - $database = self::__filter($database,$criteria); |
|
386 | + $database = self::__filter($database, $criteria); |
|
387 | 387 | // extract an array of values for the requested column |
388 | 388 | $colData = array(); |
389 | - foreach($database as $row) { |
|
389 | + foreach ($database as $row) { |
|
390 | 390 | $colData[] = $row[$field]; |
391 | 391 | } |
392 | 392 | |
@@ -423,17 +423,17 @@ discard block |
||
423 | 423 | * @return float |
424 | 424 | * |
425 | 425 | */ |
426 | - public static function DMIN($database,$field,$criteria) { |
|
427 | - $field = self::__fieldExtract($database,$field); |
|
426 | + public static function DMIN($database, $field, $criteria) { |
|
427 | + $field = self::__fieldExtract($database, $field); |
|
428 | 428 | if (is_null($field)) { |
429 | 429 | return NULL; |
430 | 430 | } |
431 | 431 | |
432 | 432 | // reduce the database to a set of rows that match all the criteria |
433 | - $database = self::__filter($database,$criteria); |
|
433 | + $database = self::__filter($database, $criteria); |
|
434 | 434 | // extract an array of values for the requested column |
435 | 435 | $colData = array(); |
436 | - foreach($database as $row) { |
|
436 | + foreach ($database as $row) { |
|
437 | 437 | $colData[] = $row[$field]; |
438 | 438 | } |
439 | 439 | |
@@ -469,17 +469,17 @@ discard block |
||
469 | 469 | * @return float |
470 | 470 | * |
471 | 471 | */ |
472 | - public static function DPRODUCT($database,$field,$criteria) { |
|
473 | - $field = self::__fieldExtract($database,$field); |
|
472 | + public static function DPRODUCT($database, $field, $criteria) { |
|
473 | + $field = self::__fieldExtract($database, $field); |
|
474 | 474 | if (is_null($field)) { |
475 | 475 | return NULL; |
476 | 476 | } |
477 | 477 | |
478 | 478 | // reduce the database to a set of rows that match all the criteria |
479 | - $database = self::__filter($database,$criteria); |
|
479 | + $database = self::__filter($database, $criteria); |
|
480 | 480 | // extract an array of values for the requested column |
481 | 481 | $colData = array(); |
482 | - foreach($database as $row) { |
|
482 | + foreach ($database as $row) { |
|
483 | 483 | $colData[] = $row[$field]; |
484 | 484 | } |
485 | 485 | |
@@ -516,17 +516,17 @@ discard block |
||
516 | 516 | * @return float |
517 | 517 | * |
518 | 518 | */ |
519 | - public static function DSTDEV($database,$field,$criteria) { |
|
520 | - $field = self::__fieldExtract($database,$field); |
|
519 | + public static function DSTDEV($database, $field, $criteria) { |
|
520 | + $field = self::__fieldExtract($database, $field); |
|
521 | 521 | if (is_null($field)) { |
522 | 522 | return NULL; |
523 | 523 | } |
524 | 524 | |
525 | 525 | // reduce the database to a set of rows that match all the criteria |
526 | - $database = self::__filter($database,$criteria); |
|
526 | + $database = self::__filter($database, $criteria); |
|
527 | 527 | // extract an array of values for the requested column |
528 | 528 | $colData = array(); |
529 | - foreach($database as $row) { |
|
529 | + foreach ($database as $row) { |
|
530 | 530 | $colData[] = $row[$field]; |
531 | 531 | } |
532 | 532 | |
@@ -563,17 +563,17 @@ discard block |
||
563 | 563 | * @return float |
564 | 564 | * |
565 | 565 | */ |
566 | - public static function DSTDEVP($database,$field,$criteria) { |
|
567 | - $field = self::__fieldExtract($database,$field); |
|
566 | + public static function DSTDEVP($database, $field, $criteria) { |
|
567 | + $field = self::__fieldExtract($database, $field); |
|
568 | 568 | if (is_null($field)) { |
569 | 569 | return NULL; |
570 | 570 | } |
571 | 571 | |
572 | 572 | // reduce the database to a set of rows that match all the criteria |
573 | - $database = self::__filter($database,$criteria); |
|
573 | + $database = self::__filter($database, $criteria); |
|
574 | 574 | // extract an array of values for the requested column |
575 | 575 | $colData = array(); |
576 | - foreach($database as $row) { |
|
576 | + foreach ($database as $row) { |
|
577 | 577 | $colData[] = $row[$field]; |
578 | 578 | } |
579 | 579 | |
@@ -609,17 +609,17 @@ discard block |
||
609 | 609 | * @return float |
610 | 610 | * |
611 | 611 | */ |
612 | - public static function DSUM($database,$field,$criteria) { |
|
613 | - $field = self::__fieldExtract($database,$field); |
|
612 | + public static function DSUM($database, $field, $criteria) { |
|
613 | + $field = self::__fieldExtract($database, $field); |
|
614 | 614 | if (is_null($field)) { |
615 | 615 | return NULL; |
616 | 616 | } |
617 | 617 | |
618 | 618 | // reduce the database to a set of rows that match all the criteria |
619 | - $database = self::__filter($database,$criteria); |
|
619 | + $database = self::__filter($database, $criteria); |
|
620 | 620 | // extract an array of values for the requested column |
621 | 621 | $colData = array(); |
622 | - foreach($database as $row) { |
|
622 | + foreach ($database as $row) { |
|
623 | 623 | $colData[] = $row[$field]; |
624 | 624 | } |
625 | 625 | |
@@ -656,17 +656,17 @@ discard block |
||
656 | 656 | * @return float |
657 | 657 | * |
658 | 658 | */ |
659 | - public static function DVAR($database,$field,$criteria) { |
|
660 | - $field = self::__fieldExtract($database,$field); |
|
659 | + public static function DVAR($database, $field, $criteria) { |
|
660 | + $field = self::__fieldExtract($database, $field); |
|
661 | 661 | if (is_null($field)) { |
662 | 662 | return NULL; |
663 | 663 | } |
664 | 664 | |
665 | 665 | // reduce the database to a set of rows that match all the criteria |
666 | - $database = self::__filter($database,$criteria); |
|
666 | + $database = self::__filter($database, $criteria); |
|
667 | 667 | // extract an array of values for the requested column |
668 | 668 | $colData = array(); |
669 | - foreach($database as $row) { |
|
669 | + foreach ($database as $row) { |
|
670 | 670 | $colData[] = $row[$field]; |
671 | 671 | } |
672 | 672 | |
@@ -703,17 +703,17 @@ discard block |
||
703 | 703 | * @return float |
704 | 704 | * |
705 | 705 | */ |
706 | - public static function DVARP($database,$field,$criteria) { |
|
707 | - $field = self::__fieldExtract($database,$field); |
|
706 | + public static function DVARP($database, $field, $criteria) { |
|
707 | + $field = self::__fieldExtract($database, $field); |
|
708 | 708 | if (is_null($field)) { |
709 | 709 | return NULL; |
710 | 710 | } |
711 | 711 | |
712 | 712 | // reduce the database to a set of rows that match all the criteria |
713 | - $database = self::__filter($database,$criteria); |
|
713 | + $database = self::__filter($database, $criteria); |
|
714 | 714 | // extract an array of values for the requested column |
715 | 715 | $colData = array(); |
716 | - foreach($database as $row) { |
|
716 | + foreach ($database as $row) { |
|
717 | 717 | $colData[] = $row[$field]; |
718 | 718 | } |
719 | 719 |
@@ -59,30 +59,30 @@ discard block |
||
59 | 59 | */ |
60 | 60 | class PHPExcel_Calculation_FormulaToken { |
61 | 61 | /* Token types */ |
62 | - const TOKEN_TYPE_NOOP = 'Noop'; |
|
63 | - const TOKEN_TYPE_OPERAND = 'Operand'; |
|
62 | + const TOKEN_TYPE_NOOP = 'Noop'; |
|
63 | + const TOKEN_TYPE_OPERAND = 'Operand'; |
|
64 | 64 | const TOKEN_TYPE_FUNCTION = 'Function'; |
65 | 65 | const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression'; |
66 | 66 | const TOKEN_TYPE_ARGUMENT = 'Argument'; |
67 | 67 | const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix'; |
68 | 68 | const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix'; |
69 | 69 | const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix'; |
70 | - const TOKEN_TYPE_WHITESPACE = 'Whitespace'; |
|
71 | - const TOKEN_TYPE_UNKNOWN = 'Unknown'; |
|
70 | + const TOKEN_TYPE_WHITESPACE = 'Whitespace'; |
|
71 | + const TOKEN_TYPE_UNKNOWN = 'Unknown'; |
|
72 | 72 | |
73 | 73 | /* Token subtypes */ |
74 | - const TOKEN_SUBTYPE_NOTHING = 'Nothing'; |
|
75 | - const TOKEN_SUBTYPE_START = 'Start'; |
|
74 | + const TOKEN_SUBTYPE_NOTHING = 'Nothing'; |
|
75 | + const TOKEN_SUBTYPE_START = 'Start'; |
|
76 | 76 | const TOKEN_SUBTYPE_STOP = 'Stop'; |
77 | 77 | const TOKEN_SUBTYPE_TEXT = 'Text'; |
78 | - const TOKEN_SUBTYPE_NUMBER = 'Number'; |
|
79 | - const TOKEN_SUBTYPE_LOGICAL = 'Logical'; |
|
78 | + const TOKEN_SUBTYPE_NUMBER = 'Number'; |
|
79 | + const TOKEN_SUBTYPE_LOGICAL = 'Logical'; |
|
80 | 80 | const TOKEN_SUBTYPE_ERROR = 'Error'; |
81 | 81 | const TOKEN_SUBTYPE_RANGE = 'Range'; |
82 | - const TOKEN_SUBTYPE_MATH = 'Math'; |
|
83 | - const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation'; |
|
84 | - const TOKEN_SUBTYPE_INTERSECTION = 'Intersection'; |
|
85 | - const TOKEN_SUBTYPE_UNION = 'Union'; |
|
82 | + const TOKEN_SUBTYPE_MATH = 'Math'; |
|
83 | + const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation'; |
|
84 | + const TOKEN_SUBTYPE_INTERSECTION = 'Intersection'; |
|
85 | + const TOKEN_SUBTYPE_UNION = 'Union'; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Value |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) |
116 | 116 | { |
117 | 117 | // Initialise values |
118 | - $this->_value = $pValue; |
|
119 | - $this->_tokenType = $pTokenType; |
|
120 | - $this->_tokenSubType = $pTokenSubType; |
|
118 | + $this->_value = $pValue; |
|
119 | + $this->_tokenType = $pTokenType; |
|
120 | + $this->_tokenSubType = $pTokenSubType; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -105,72 +105,72 @@ |
||
105 | 105 | */ |
106 | 106 | private $_tokenSubType; |
107 | 107 | |
108 | - /** |
|
109 | - * Create a new PHPExcel_Calculation_FormulaToken |
|
110 | - * |
|
111 | - * @param string $pValue |
|
112 | - * @param string $pTokenType Token type (represented by TOKEN_TYPE_*) |
|
113 | - * @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*) |
|
114 | - */ |
|
115 | - public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) |
|
116 | - { |
|
117 | - // Initialise values |
|
118 | - $this->_value = $pValue; |
|
119 | - $this->_tokenType = $pTokenType; |
|
120 | - $this->_tokenSubType = $pTokenSubType; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Get Value |
|
125 | - * |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - public function getValue() { |
|
129 | - return $this->_value; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Set Value |
|
134 | - * |
|
135 | - * @param string $value |
|
136 | - */ |
|
137 | - public function setValue($value) { |
|
138 | - $this->_value = $value; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Get Token Type (represented by TOKEN_TYPE_*) |
|
143 | - * |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - public function getTokenType() { |
|
147 | - return $this->_tokenType; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Set Token Type |
|
152 | - * |
|
153 | - * @param string $value |
|
154 | - */ |
|
155 | - public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) { |
|
156 | - $this->_tokenType = $value; |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Get Token SubType (represented by TOKEN_SUBTYPE_*) |
|
161 | - * |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function getTokenSubType() { |
|
165 | - return $this->_tokenSubType; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Set Token SubType |
|
170 | - * |
|
171 | - * @param string $value |
|
172 | - */ |
|
173 | - public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) { |
|
174 | - $this->_tokenSubType = $value; |
|
175 | - } |
|
108 | + /** |
|
109 | + * Create a new PHPExcel_Calculation_FormulaToken |
|
110 | + * |
|
111 | + * @param string $pValue |
|
112 | + * @param string $pTokenType Token type (represented by TOKEN_TYPE_*) |
|
113 | + * @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*) |
|
114 | + */ |
|
115 | + public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) |
|
116 | + { |
|
117 | + // Initialise values |
|
118 | + $this->_value = $pValue; |
|
119 | + $this->_tokenType = $pTokenType; |
|
120 | + $this->_tokenSubType = $pTokenSubType; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Get Value |
|
125 | + * |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + public function getValue() { |
|
129 | + return $this->_value; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Set Value |
|
134 | + * |
|
135 | + * @param string $value |
|
136 | + */ |
|
137 | + public function setValue($value) { |
|
138 | + $this->_value = $value; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Get Token Type (represented by TOKEN_TYPE_*) |
|
143 | + * |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + public function getTokenType() { |
|
147 | + return $this->_tokenType; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Set Token Type |
|
152 | + * |
|
153 | + * @param string $value |
|
154 | + */ |
|
155 | + public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) { |
|
156 | + $this->_tokenType = $value; |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Get Token SubType (represented by TOKEN_SUBTYPE_*) |
|
161 | + * |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + public function getTokenSubType() { |
|
165 | + return $this->_tokenSubType; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Set Token SubType |
|
170 | + * |
|
171 | + * @param string $value |
|
172 | + */ |
|
173 | + public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) { |
|
174 | + $this->_tokenSubType = $value; |
|
175 | + } |
|
176 | 176 | } |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class PHPExcel_Calculation_Function { |
37 | 37 | /* Function categories */ |
38 | - const CATEGORY_CUBE = 'Cube'; |
|
38 | + const CATEGORY_CUBE = 'Cube'; |
|
39 | 39 | const CATEGORY_DATABASE = 'Database'; |
40 | - const CATEGORY_DATE_AND_TIME = 'Date and Time'; |
|
40 | + const CATEGORY_DATE_AND_TIME = 'Date and Time'; |
|
41 | 41 | const CATEGORY_ENGINEERING = 'Engineering'; |
42 | 42 | const CATEGORY_FINANCIAL = 'Financial'; |
43 | 43 | const CATEGORY_INFORMATION = 'Information'; |
44 | - const CATEGORY_LOGICAL = 'Logical'; |
|
45 | - const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference'; |
|
44 | + const CATEGORY_LOGICAL = 'Logical'; |
|
45 | + const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference'; |
|
46 | 46 | const CATEGORY_MATH_AND_TRIG = 'Math and Trig'; |
47 | - const CATEGORY_STATISTICAL = 'Statistical'; |
|
47 | + const CATEGORY_STATISTICAL = 'Statistical'; |
|
48 | 48 | const CATEGORY_TEXT_AND_DATA = 'Text and Data'; |
49 | 49 | |
50 | 50 | /** |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | { |
81 | 81 | if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) { |
82 | 82 | // Initialise values |
83 | - $this->_category = $pCategory; |
|
84 | - $this->_excelName = $pExcelName; |
|
85 | - $this->_phpExcelName = $pPHPExcelName; |
|
83 | + $this->_category = $pCategory; |
|
84 | + $this->_excelName = $pExcelName; |
|
85 | + $this->_phpExcelName = $pPHPExcelName; |
|
86 | 86 | } else { |
87 | 87 | throw new Exception("Invalid parameters passed."); |
88 | 88 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @throws Exception |
105 | 105 | */ |
106 | 106 | public function setCategory($value = null) { |
107 | - if (!is_null($value)) { |
|
107 | + if ( ! is_null($value)) { |
|
108 | 108 | $this->_category = $value; |
109 | 109 | } else { |
110 | 110 | throw new Exception("Invalid parameter passed."); |
@@ -68,82 +68,82 @@ |
||
68 | 68 | */ |
69 | 69 | private $_phpExcelName; |
70 | 70 | |
71 | - /** |
|
72 | - * Create a new PHPExcel_Calculation_Function |
|
73 | - * |
|
74 | - * @param string $pCategory Category (represented by CATEGORY_*) |
|
75 | - * @param string $pExcelName Excel function name |
|
76 | - * @param string $pPHPExcelName PHPExcel function mapping |
|
77 | - * @throws Exception |
|
78 | - */ |
|
79 | - public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL) |
|
80 | - { |
|
81 | - if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) { |
|
82 | - // Initialise values |
|
83 | - $this->_category = $pCategory; |
|
84 | - $this->_excelName = $pExcelName; |
|
85 | - $this->_phpExcelName = $pPHPExcelName; |
|
86 | - } else { |
|
87 | - throw new Exception("Invalid parameters passed."); |
|
88 | - } |
|
89 | - } |
|
71 | + /** |
|
72 | + * Create a new PHPExcel_Calculation_Function |
|
73 | + * |
|
74 | + * @param string $pCategory Category (represented by CATEGORY_*) |
|
75 | + * @param string $pExcelName Excel function name |
|
76 | + * @param string $pPHPExcelName PHPExcel function mapping |
|
77 | + * @throws Exception |
|
78 | + */ |
|
79 | + public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL) |
|
80 | + { |
|
81 | + if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) { |
|
82 | + // Initialise values |
|
83 | + $this->_category = $pCategory; |
|
84 | + $this->_excelName = $pExcelName; |
|
85 | + $this->_phpExcelName = $pPHPExcelName; |
|
86 | + } else { |
|
87 | + throw new Exception("Invalid parameters passed."); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Get Category (represented by CATEGORY_*) |
|
93 | - * |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function getCategory() { |
|
97 | - return $this->_category; |
|
98 | - } |
|
91 | + /** |
|
92 | + * Get Category (represented by CATEGORY_*) |
|
93 | + * |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + public function getCategory() { |
|
97 | + return $this->_category; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * Set Category (represented by CATEGORY_*) |
|
102 | - * |
|
103 | - * @param string $value |
|
104 | - * @throws Exception |
|
105 | - */ |
|
106 | - public function setCategory($value = null) { |
|
107 | - if (!is_null($value)) { |
|
108 | - $this->_category = $value; |
|
109 | - } else { |
|
110 | - throw new Exception("Invalid parameter passed."); |
|
111 | - } |
|
112 | - } |
|
100 | + /** |
|
101 | + * Set Category (represented by CATEGORY_*) |
|
102 | + * |
|
103 | + * @param string $value |
|
104 | + * @throws Exception |
|
105 | + */ |
|
106 | + public function setCategory($value = null) { |
|
107 | + if (!is_null($value)) { |
|
108 | + $this->_category = $value; |
|
109 | + } else { |
|
110 | + throw new Exception("Invalid parameter passed."); |
|
111 | + } |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Get Excel name |
|
116 | - * |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function getExcelName() { |
|
120 | - return $this->_excelName; |
|
121 | - } |
|
114 | + /** |
|
115 | + * Get Excel name |
|
116 | + * |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function getExcelName() { |
|
120 | + return $this->_excelName; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Set Excel name |
|
125 | - * |
|
126 | - * @param string $value |
|
127 | - */ |
|
128 | - public function setExcelName($value) { |
|
129 | - $this->_excelName = $value; |
|
130 | - } |
|
123 | + /** |
|
124 | + * Set Excel name |
|
125 | + * |
|
126 | + * @param string $value |
|
127 | + */ |
|
128 | + public function setExcelName($value) { |
|
129 | + $this->_excelName = $value; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Get PHPExcel name |
|
134 | - * |
|
135 | - * @return string |
|
136 | - */ |
|
137 | - public function getPHPExcelName() { |
|
138 | - return $this->_phpExcelName; |
|
139 | - } |
|
132 | + /** |
|
133 | + * Get PHPExcel name |
|
134 | + * |
|
135 | + * @return string |
|
136 | + */ |
|
137 | + public function getPHPExcelName() { |
|
138 | + return $this->_phpExcelName; |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Set PHPExcel name |
|
143 | - * |
|
144 | - * @param string $value |
|
145 | - */ |
|
146 | - public function setPHPExcelName($value) { |
|
147 | - $this->_phpExcelName = $value; |
|
148 | - } |
|
141 | + /** |
|
142 | + * Set PHPExcel name |
|
143 | + * |
|
144 | + * @param string $value |
|
145 | + */ |
|
146 | + public function setPHPExcelName($value) { |
|
147 | + $this->_phpExcelName = $value; |
|
148 | + } |
|
149 | 149 | } |
@@ -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 | |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | class PHPExcel_Calculation_Functions { |
60 | 60 | |
61 | 61 | /** constants */ |
62 | - const COMPATIBILITY_EXCEL = 'Excel'; |
|
62 | + const COMPATIBILITY_EXCEL = 'Excel'; |
|
63 | 63 | const COMPATIBILITY_GNUMERIC = 'Gnumeric'; |
64 | - const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc'; |
|
64 | + const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc'; |
|
65 | 65 | |
66 | 66 | const RETURNDATE_PHP_NUMERIC = 'P'; |
67 | 67 | const RETURNDATE_PHP_OBJECT = 'O'; |
68 | - const RETURNDATE_EXCEL = 'E'; |
|
68 | + const RETURNDATE_EXCEL = 'E'; |
|
69 | 69 | |
70 | 70 | |
71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @access private |
75 | 75 | * @var string |
76 | 76 | */ |
77 | - protected static $compatibilityMode = self::COMPATIBILITY_EXCEL; |
|
77 | + protected static $compatibilityMode = self::COMPATIBILITY_EXCEL; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Data Type to use when returning date values |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @access private |
83 | 83 | * @var string |
84 | 84 | */ |
85 | - protected static $ReturnDateType = self::RETURNDATE_EXCEL; |
|
85 | + protected static $ReturnDateType = self::RETURNDATE_EXCEL; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * List of error codes |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @access private |
91 | 91 | * @var array |
92 | 92 | */ |
93 | - protected static $_errorCodes = array( 'null' => '#NULL!', |
|
93 | + protected static $_errorCodes = array('null' => '#NULL!', |
|
94 | 94 | 'divisionbyzero' => '#DIV/0!', |
95 | 95 | 'value' => '#VALUE!', |
96 | 96 | 'reference' => '#REF!', |
@@ -292,29 +292,29 @@ discard block |
||
292 | 292 | |
293 | 293 | |
294 | 294 | public static function isMatrixValue($idx) { |
295 | - return ((substr_count($idx,'.') <= 1) || (preg_match('/\.[A-Z]/',$idx) > 0)); |
|
295 | + return ((substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0)); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
299 | 299 | public static function isValue($idx) { |
300 | - return (substr_count($idx,'.') == 0); |
|
300 | + return (substr_count($idx, '.') == 0); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
304 | 304 | public static function isCellValue($idx) { |
305 | - return (substr_count($idx,'.') > 1); |
|
305 | + return (substr_count($idx, '.') > 1); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
309 | 309 | public static function _ifCondition($condition) { |
310 | - $condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition); |
|
311 | - if (!in_array($condition{0},array('>', '<', '='))) { |
|
312 | - if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); } |
|
310 | + $condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition); |
|
311 | + if ( ! in_array($condition{0},array('>', '<', '='))) { |
|
312 | + if ( ! is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); } |
|
313 | 313 | return '='.$condition; |
314 | 314 | } else { |
315 | - preg_match('/([<>=]+)(.*)/',$condition,$matches); |
|
316 | - list(,$operator,$operand) = $matches; |
|
317 | - if (!is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); } |
|
315 | + preg_match('/([<>=]+)(.*)/', $condition, $matches); |
|
316 | + list(,$operator, $operand) = $matches; |
|
317 | + if ( ! is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); } |
|
318 | 318 | return $operator.$operand; |
319 | 319 | } |
320 | 320 | } // function _ifCondition() |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | * @return boolean |
328 | 328 | */ |
329 | 329 | public static function ERROR_TYPE($value = '') { |
330 | - $value = self::flattenSingleValue($value); |
|
330 | + $value = self::flattenSingleValue($value); |
|
331 | 331 | |
332 | 332 | $i = 1; |
333 | - foreach(self::$_errorCodes as $errorCode) { |
|
333 | + foreach (self::$_errorCodes as $errorCode) { |
|
334 | 334 | if ($value === $errorCode) { |
335 | 335 | return $i; |
336 | 336 | } |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * @return boolean |
348 | 348 | */ |
349 | 349 | public static function IS_BLANK($value = NULL) { |
350 | - if (!is_null($value)) { |
|
351 | - $value = self::flattenSingleValue($value); |
|
350 | + if ( ! is_null($value)) { |
|
351 | + $value = self::flattenSingleValue($value); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | return is_null($value); |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | * @return boolean |
363 | 363 | */ |
364 | 364 | public static function IS_ERR($value = '') { |
365 | - $value = self::flattenSingleValue($value); |
|
365 | + $value = self::flattenSingleValue($value); |
|
366 | 366 | |
367 | - return self::IS_ERROR($value) && (!self::IS_NA($value)); |
|
367 | + return self::IS_ERROR($value) && ( ! self::IS_NA($value)); |
|
368 | 368 | } // function IS_ERR() |
369 | 369 | |
370 | 370 | |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | * @return boolean |
376 | 376 | */ |
377 | 377 | public static function IS_ERROR($value = '') { |
378 | - $value = self::flattenSingleValue($value); |
|
378 | + $value = self::flattenSingleValue($value); |
|
379 | 379 | |
380 | - if (!is_string($value)) |
|
380 | + if ( ! is_string($value)) |
|
381 | 381 | return false; |
382 | 382 | return in_array($value, array_values(self::$_errorCodes)); |
383 | 383 | } // function IS_ERROR() |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * @return boolean |
391 | 391 | */ |
392 | 392 | public static function IS_NA($value = '') { |
393 | - $value = self::flattenSingleValue($value); |
|
393 | + $value = self::flattenSingleValue($value); |
|
394 | 394 | |
395 | 395 | return ($value === self::NA()); |
396 | 396 | } // function IS_NA() |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | |
408 | 408 | if ($value === NULL) |
409 | 409 | return self::NAME(); |
410 | - if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) |
|
410 | + if ((is_bool($value)) || ((is_string($value)) && ( ! is_numeric($value)))) |
|
411 | 411 | return self::VALUE(); |
412 | 412 | return ($value % 2 == 0); |
413 | 413 | } // function IS_EVEN() |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | |
425 | 425 | if ($value === NULL) |
426 | 426 | return self::NAME(); |
427 | - if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) |
|
427 | + if ((is_bool($value)) || ((is_string($value)) && ( ! is_numeric($value)))) |
|
428 | 428 | return self::VALUE(); |
429 | 429 | return (abs($value) % 2 == 1); |
430 | 430 | } // function IS_ODD() |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * @return boolean |
438 | 438 | */ |
439 | 439 | public static function IS_NUMBER($value = NULL) { |
440 | - $value = self::flattenSingleValue($value); |
|
440 | + $value = self::flattenSingleValue($value); |
|
441 | 441 | |
442 | 442 | if (is_string($value)) { |
443 | 443 | return False; |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @return boolean |
454 | 454 | */ |
455 | 455 | public static function IS_LOGICAL($value = NULL) { |
456 | - $value = self::flattenSingleValue($value); |
|
456 | + $value = self::flattenSingleValue($value); |
|
457 | 457 | |
458 | 458 | return is_bool($value); |
459 | 459 | } // function IS_LOGICAL() |
@@ -466,9 +466,9 @@ discard block |
||
466 | 466 | * @return boolean |
467 | 467 | */ |
468 | 468 | public static function IS_TEXT($value = NULL) { |
469 | - $value = self::flattenSingleValue($value); |
|
469 | + $value = self::flattenSingleValue($value); |
|
470 | 470 | |
471 | - return (is_string($value) && !self::IS_ERROR($value)); |
|
471 | + return (is_string($value) && ! self::IS_ERROR($value)); |
|
472 | 472 | } // function IS_TEXT() |
473 | 473 | |
474 | 474 | |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @return boolean |
480 | 480 | */ |
481 | 481 | public static function IS_NONTEXT($value = NULL) { |
482 | - return !self::IS_TEXT($value); |
|
482 | + return ! self::IS_TEXT($value); |
|
483 | 483 | } // function IS_NONTEXT() |
484 | 484 | |
485 | 485 | |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | * Array or Matrix 64 |
549 | 549 | */ |
550 | 550 | public static function TYPE($value = NULL) { |
551 | - $value = self::flattenArrayIndexed($value); |
|
551 | + $value = self::flattenArrayIndexed($value); |
|
552 | 552 | if (is_array($value) && (count($value) > 1)) { |
553 | 553 | $a = array_keys($value); |
554 | 554 | $a = array_pop($a); |
@@ -559,20 +559,20 @@ discard block |
||
559 | 559 | } elseif (self::isMatrixValue($a)) { |
560 | 560 | return 64; |
561 | 561 | } |
562 | - } elseif(empty($value)) { |
|
562 | + } elseif (empty($value)) { |
|
563 | 563 | // Empty Cell |
564 | 564 | return 1; |
565 | 565 | } |
566 | - $value = self::flattenSingleValue($value); |
|
566 | + $value = self::flattenSingleValue($value); |
|
567 | 567 | |
568 | 568 | if (($value === NULL) || (is_float($value)) || (is_int($value))) { |
569 | 569 | return 1; |
570 | - } elseif(is_bool($value)) { |
|
570 | + } elseif (is_bool($value)) { |
|
571 | 571 | return 4; |
572 | - } elseif(is_array($value)) { |
|
572 | + } elseif (is_array($value)) { |
|
573 | 573 | return 64; |
574 | 574 | break; |
575 | - } elseif(is_string($value)) { |
|
575 | + } elseif (is_string($value)) { |
|
576 | 576 | // Errors |
577 | 577 | if ((strlen($value) > 0) && ($value{0} == '#')) { |
578 | 578 | return 16; |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @return array Flattened array |
591 | 591 | */ |
592 | 592 | public static function flattenArray($array) { |
593 | - if (!is_array($array)) { |
|
593 | + if ( ! is_array($array)) { |
|
594 | 594 | return (array) $array; |
595 | 595 | } |
596 | 596 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @return array Flattened array |
623 | 623 | */ |
624 | 624 | public static function flattenArrayIndexed($array) { |
625 | - if (!is_array($array)) { |
|
625 | + if ( ! is_array($array)) { |
|
626 | 626 | return (array) $array; |
627 | 627 | } |
628 | 628 | |
@@ -669,27 +669,27 @@ discard block |
||
669 | 669 | // These functions aren't available in Windows implementations of PHP prior to version 5.3.0 |
670 | 670 | // So we test if they do exist for this version of PHP/operating platform; and if not we create them |
671 | 671 | // |
672 | -if (!function_exists('acosh')) { |
|
672 | +if ( ! function_exists('acosh')) { |
|
673 | 673 | function acosh($x) { |
674 | 674 | return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2)); |
675 | 675 | } // function acosh() |
676 | 676 | } |
677 | 677 | |
678 | -if (!function_exists('asinh')) { |
|
678 | +if ( ! function_exists('asinh')) { |
|
679 | 679 | function asinh($x) { |
680 | 680 | return log($x + sqrt(1 + $x * $x)); |
681 | 681 | } // function asinh() |
682 | 682 | } |
683 | 683 | |
684 | -if (!function_exists('atanh')) { |
|
684 | +if ( ! function_exists('atanh')) { |
|
685 | 685 | function atanh($x) { |
686 | 686 | return (log(1 + $x) - log(1 - $x)) / 2; |
687 | 687 | } // function atanh() |
688 | 688 | } |
689 | 689 | |
690 | -if (!function_exists('money_format')) { |
|
690 | +if ( ! function_exists('money_format')) { |
|
691 | 691 | function money_format($format, $number) { |
692 | - $regex = array( '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?(?:#([0-9]+))?', |
|
692 | + $regex = array('/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?(?:#([0-9]+))?', |
|
693 | 693 | '(?:\.([0-9]+))?([in%])/' |
694 | 694 | ); |
695 | 695 | $regex = implode('', $regex); |
@@ -698,19 +698,19 @@ discard block |
||
698 | 698 | } |
699 | 699 | $locale = localeconv(); |
700 | 700 | $number = floatval($number); |
701 | - if (!preg_match($regex, $format, $fmatch)) { |
|
701 | + if ( ! preg_match($regex, $format, $fmatch)) { |
|
702 | 702 | trigger_error("No format specified or invalid format", E_USER_WARNING); |
703 | 703 | return $number; |
704 | 704 | } |
705 | - $flags = array( 'fillchar' => preg_match('/\=(.)/', $fmatch[1], $match) ? $match[1] : ' ', |
|
705 | + $flags = array('fillchar' => preg_match('/\=(.)/', $fmatch[1], $match) ? $match[1] : ' ', |
|
706 | 706 | 'nogroup' => preg_match('/\^/', $fmatch[1]) > 0, |
707 | 707 | 'usesignal' => preg_match('/\+|\(/', $fmatch[1], $match) ? $match[0] : '+', |
708 | 708 | 'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0, |
709 | 709 | 'isleft' => preg_match('/\-/', $fmatch[1]) > 0 |
710 | 710 | ); |
711 | - $width = trim($fmatch[2]) ? (int)$fmatch[2] : 0; |
|
712 | - $left = trim($fmatch[3]) ? (int)$fmatch[3] : 0; |
|
713 | - $right = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits']; |
|
711 | + $width = trim($fmatch[2]) ? (int) $fmatch[2] : 0; |
|
712 | + $left = trim($fmatch[3]) ? (int) $fmatch[3] : 0; |
|
713 | + $right = trim($fmatch[4]) ? (int) $fmatch[4] : $locale['int_frac_digits']; |
|
714 | 714 | $conversion = $fmatch[5]; |
715 | 715 | $positive = true; |
716 | 716 | if ($number < 0) { |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | } |
720 | 720 | $letter = $positive ? 'p' : 'n'; |
721 | 721 | $prefix = $suffix = $cprefix = $csuffix = $signal = ''; |
722 | - if (!$positive) { |
|
722 | + if ( ! $positive) { |
|
723 | 723 | $signal = $locale['negative_sign']; |
724 | 724 | switch (true) { |
725 | 725 | case $locale['n_sign_posn'] == 0 || $flags['usesignal'] == '(': |
@@ -740,23 +740,22 @@ discard block |
||
740 | 740 | break; |
741 | 741 | } |
742 | 742 | } |
743 | - if (!$flags['nosimbol']) { |
|
743 | + if ( ! $flags['nosimbol']) { |
|
744 | 744 | $currency = $cprefix; |
745 | 745 | $currency .= ($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']); |
746 | 746 | $currency .= $csuffix; |
747 | - $currency = iconv('ISO-8859-1','UTF-8',$currency); |
|
747 | + $currency = iconv('ISO-8859-1', 'UTF-8', $currency); |
|
748 | 748 | } else { |
749 | 749 | $currency = ''; |
750 | 750 | } |
751 | 751 | $space = $locale["{$letter}_sep_by_space"] ? ' ' : ''; |
752 | 752 | |
753 | - if (!isset($locale['mon_decimal_point']) || empty($locale['mon_decimal_point'])) { |
|
754 | - $locale['mon_decimal_point'] = (!isset($locale['decimal_point']) || empty($locale['decimal_point'])) ? |
|
755 | - $locale['decimal_point'] : |
|
756 | - '.'; |
|
753 | + if ( ! isset($locale['mon_decimal_point']) || empty($locale['mon_decimal_point'])) { |
|
754 | + $locale['mon_decimal_point'] = ( ! isset($locale['decimal_point']) || empty($locale['decimal_point'])) ? |
|
755 | + $locale['decimal_point'] : '.'; |
|
757 | 756 | } |
758 | 757 | |
759 | - $number = number_format($number, $right, $locale['mon_decimal_point'], $flags['nogroup'] ? '' : $locale['mon_thousands_sep'] ); |
|
758 | + $number = number_format($number, $right, $locale['mon_decimal_point'], $flags['nogroup'] ? '' : $locale['mon_thousands_sep']); |
|
760 | 759 | $number = explode($locale['mon_decimal_point'], $number); |
761 | 760 | |
762 | 761 | $n = strlen($prefix) + strlen($currency); |
@@ -764,14 +763,14 @@ discard block |
||
764 | 763 | if ($flags['isleft']) { |
765 | 764 | $number[0] .= str_repeat($flags['fillchar'], $left - $n); |
766 | 765 | } else { |
767 | - $number[0] = str_repeat($flags['fillchar'], $left - $n) . $number[0]; |
|
766 | + $number[0] = str_repeat($flags['fillchar'], $left - $n).$number[0]; |
|
768 | 767 | } |
769 | 768 | } |
770 | 769 | $number = implode($locale['mon_decimal_point'], $number); |
771 | 770 | if ($locale["{$letter}_cs_precedes"]) { |
772 | - $number = $prefix . $currency . $space . $number . $suffix; |
|
771 | + $number = $prefix.$currency.$space.$number.$suffix; |
|
773 | 772 | } else { |
774 | - $number = $prefix . $number . $space . $currency . $suffix; |
|
773 | + $number = $prefix.$number.$space.$currency.$suffix; |
|
775 | 774 | } |
776 | 775 | if ($width > 0) { |
777 | 776 | $number = str_pad($number, $width, $flags['fillchar'], $flags['isleft'] ? STR_PAD_RIGHT : STR_PAD_LEFT); |
@@ -786,25 +785,25 @@ discard block |
||
786 | 785 | // Strangely, PHP doesn't have a mb_str_replace multibyte function |
787 | 786 | // As we'll only ever use this function with UTF-8 characters, we can simply "hard-code" the character set |
788 | 787 | // |
789 | -if ((!function_exists('mb_str_replace')) && |
|
788 | +if (( ! function_exists('mb_str_replace')) && |
|
790 | 789 | (function_exists('mb_substr')) && (function_exists('mb_strlen')) && (function_exists('mb_strpos'))) { |
791 | 790 | function mb_str_replace($search, $replace, $subject) { |
792 | - if(is_array($subject)) { |
|
791 | + if (is_array($subject)) { |
|
793 | 792 | $ret = array(); |
794 | - foreach($subject as $key => $val) { |
|
793 | + foreach ($subject as $key => $val) { |
|
795 | 794 | $ret[$key] = mb_str_replace($search, $replace, $val); |
796 | 795 | } |
797 | 796 | return $ret; |
798 | 797 | } |
799 | 798 | |
800 | - foreach((array) $search as $key => $s) { |
|
801 | - if($s == '') { |
|
799 | + foreach ((array) $search as $key => $s) { |
|
800 | + if ($s == '') { |
|
802 | 801 | continue; |
803 | 802 | } |
804 | - $r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : ''); |
|
803 | + $r = ! is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : ''); |
|
805 | 804 | $pos = mb_strpos($subject, $s, 0, 'UTF-8'); |
806 | - while($pos !== false) { |
|
807 | - $subject = mb_substr($subject, 0, $pos, 'UTF-8') . $r . mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8'); |
|
805 | + while ($pos !== false) { |
|
806 | + $subject = mb_substr($subject, 0, $pos, 'UTF-8').$r.mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8'); |
|
808 | 807 | $pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8'); |
809 | 808 | } |
810 | 809 | } |
@@ -377,8 +377,9 @@ discard block |
||
377 | 377 | public static function IS_ERROR($value = '') { |
378 | 378 | $value = self::flattenSingleValue($value); |
379 | 379 | |
380 | - if (!is_string($value)) |
|
381 | - return false; |
|
380 | + if (!is_string($value)) { |
|
381 | + return false; |
|
382 | + } |
|
382 | 383 | return in_array($value, array_values(self::$_errorCodes)); |
383 | 384 | } // function IS_ERROR() |
384 | 385 | |
@@ -405,10 +406,12 @@ discard block |
||
405 | 406 | public static function IS_EVEN($value = NULL) { |
406 | 407 | $value = self::flattenSingleValue($value); |
407 | 408 | |
408 | - if ($value === NULL) |
|
409 | - return self::NAME(); |
|
410 | - if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) |
|
411 | - return self::VALUE(); |
|
409 | + if ($value === NULL) { |
|
410 | + return self::NAME(); |
|
411 | + } |
|
412 | + if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) { |
|
413 | + return self::VALUE(); |
|
414 | + } |
|
412 | 415 | return ($value % 2 == 0); |
413 | 416 | } // function IS_EVEN() |
414 | 417 | |
@@ -422,10 +425,12 @@ discard block |
||
422 | 425 | public static function IS_ODD($value = NULL) { |
423 | 426 | $value = self::flattenSingleValue($value); |
424 | 427 | |
425 | - if ($value === NULL) |
|
426 | - return self::NAME(); |
|
427 | - if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) |
|
428 | - return self::VALUE(); |
|
428 | + if ($value === NULL) { |
|
429 | + return self::NAME(); |
|
430 | + } |
|
431 | + if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) { |
|
432 | + return self::VALUE(); |
|
433 | + } |
|
429 | 434 | return (abs($value) % 2 == 1); |
430 | 435 | } // function IS_ODD() |
431 | 436 |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * IS_EVEN |
401 | 401 | * |
402 | 402 | * @param mixed $value Value to check |
403 | - * @return boolean |
|
403 | + * @return string|boolean |
|
404 | 404 | */ |
405 | 405 | public static function IS_EVEN($value = NULL) { |
406 | 406 | $value = self::flattenSingleValue($value); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * IS_ODD |
418 | 418 | * |
419 | 419 | * @param mixed $value Value to check |
420 | - * @return boolean |
|
420 | + * @return string|boolean |
|
421 | 421 | */ |
422 | 422 | public static function IS_ODD($value = NULL) { |
423 | 423 | $value = self::flattenSingleValue($value); |
@@ -688,6 +688,12 @@ discard block |
||
688 | 688 | } |
689 | 689 | |
690 | 690 | if (!function_exists('money_format')) { |
691 | + |
|
692 | + /** |
|
693 | + * @param string $format |
|
694 | + * |
|
695 | + * @return string |
|
696 | + */ |
|
691 | 697 | function money_format($format, $number) { |
692 | 698 | $regex = array( '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?(?:#([0-9]+))?', |
693 | 699 | '(?:\.([0-9]+))?([in%])/' |