Skip to content

Commit 3c3154c

Browse files
author
MarkBaker
committed
PSR-2 variable naming for caching classes, remove leading underscores
1 parent e885ef9 commit 3c3154c

16 files changed

+550
-549
lines changed

Classes/PHPExcel/CachedObjectStorage/APC.php

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
3333
* @access private
3434
* @var string
3535
*/
36-
private $_cachePrefix = null;
36+
private $cachePrefix = null;
3737

3838
/**
3939
* Cache timeout
4040
*
4141
* @access private
4242
* @var integer
4343
*/
44-
private $_cacheTime = 600;
44+
private $cacheTime = 600;
4545

4646
/**
4747
* Store cell data in cache for the current cell object if it's "dirty",
@@ -51,22 +51,22 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
5151
* @return void
5252
* @throws PHPExcel_Exception
5353
*/
54-
protected function _storeData()
54+
protected function storeData()
5555
{
56-
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
57-
$this->_currentObject->detach();
56+
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
57+
$this->currentObject->detach();
5858

5959
if (!apc_store(
60-
$this->_cachePrefix . $this->_currentObjectID . '.cache',
61-
serialize($this->_currentObject),
62-
$this->_cacheTime
60+
$this->cachePrefix . $this->currentObjectID . '.cache',
61+
serialize($this->currentObject),
62+
$this->cacheTime
6363
)) {
6464
$this->__destruct();
65-
throw new PHPExcel_Exception('Failed to store cell ' . $this->_currentObjectID . ' in APC');
65+
throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in APC');
6666
}
67-
$this->_currentCellIsDirty = false;
67+
$this->currentCellIsDirty = false;
6868
}
69-
$this->_currentObjectID = $this->_currentObject = null;
69+
$this->currentObjectID = $this->currentObject = null;
7070
}
7171

7272
/**
@@ -80,14 +80,14 @@ protected function _storeData()
8080
*/
8181
public function addCacheData($pCoord, PHPExcel_Cell $cell)
8282
{
83-
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
84-
$this->_storeData();
83+
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
84+
$this->storeData();
8585
}
86-
$this->_cellCache[$pCoord] = true;
86+
$this->cellCache[$pCoord] = true;
8787

88-
$this->_currentObjectID = $pCoord;
89-
$this->_currentObject = $cell;
90-
$this->_currentCellIsDirty = true;
88+
$this->currentObjectID = $pCoord;
89+
$this->currentObject = $cell;
90+
$this->currentCellIsDirty = true;
9191

9292
return $cell;
9393
}
@@ -104,11 +104,11 @@ public function isDataSet($pCoord)
104104
{
105105
// Check if the requested entry is the current object, or exists in the cache
106106
if (parent::isDataSet($pCoord)) {
107-
if ($this->_currentObjectID == $pCoord) {
107+
if ($this->currentObjectID == $pCoord) {
108108
return true;
109109
}
110110
// Check if the requested entry still exists in apc
111-
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
111+
$success = apc_fetch($this->cachePrefix.$pCoord.'.cache');
112112
if ($success === false) {
113113
// Entry no longer exists in APC, so clear it from the cache array
114114
parent::deleteCacheData($pCoord);
@@ -129,14 +129,14 @@ public function isDataSet($pCoord)
129129
*/
130130
public function getCacheData($pCoord)
131131
{
132-
if ($pCoord === $this->_currentObjectID) {
133-
return $this->_currentObject;
132+
if ($pCoord === $this->currentObjectID) {
133+
return $this->currentObject;
134134
}
135-
$this->_storeData();
135+
$this->storeData();
136136

137137
// Check if the entry that has been requested actually exists
138138
if (parent::isDataSet($pCoord)) {
139-
$obj = apc_fetch($this->_cachePrefix . $pCoord . '.cache');
139+
$obj = apc_fetch($this->cachePrefix . $pCoord . '.cache');
140140
if ($obj === false) {
141141
// Entry no longer exists in APC, so clear it from the cache array
142142
parent::deleteCacheData($pCoord);
@@ -148,13 +148,13 @@ public function getCacheData($pCoord)
148148
}
149149

150150
// Set current entry to the requested entry
151-
$this->_currentObjectID = $pCoord;
152-
$this->_currentObject = unserialize($obj);
151+
$this->currentObjectID = $pCoord;
152+
$this->currentObject = unserialize($obj);
153153
// Re-attach this as the cell's parent
154-
$this->_currentObject->attach($this);
154+
$this->currentObject->attach($this);
155155

156156
// Return requested entry
157-
return $this->_currentObject;
157+
return $this->currentObject;
158158
}
159159

160160
/**
@@ -164,8 +164,8 @@ public function getCacheData($pCoord)
164164
*/
165165
public function getCellList()
166166
{
167-
if ($this->_currentObjectID !== null) {
168-
$this->_storeData();
167+
if ($this->currentObjectID !== null) {
168+
$this->storeData();
169169
}
170170

171171
return parent::getCellList();
@@ -181,7 +181,7 @@ public function getCellList()
181181
public function deleteCacheData($pCoord)
182182
{
183183
// Delete the entry from APC
184-
apc_delete($this->_cachePrefix.$pCoord.'.cache');
184+
apc_delete($this->cachePrefix.$pCoord.'.cache');
185185

186186
// Delete the entry from our cell address array
187187
parent::deleteCacheData($pCoord);
@@ -199,24 +199,24 @@ public function copyCellCollection(PHPExcel_Worksheet $parent)
199199
{
200200
parent::copyCellCollection($parent);
201201
// Get a new id for the new file name
202-
$baseUnique = $this->_getUniqueID();
202+
$baseUnique = $this->getUniqueID();
203203
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
204204
$cacheList = $this->getCellList();
205205
foreach ($cacheList as $cellID) {
206-
if ($cellID != $this->_currentObjectID) {
207-
$obj = apc_fetch($this->_cachePrefix . $cellID . '.cache');
206+
if ($cellID != $this->currentObjectID) {
207+
$obj = apc_fetch($this->cachePrefix . $cellID . '.cache');
208208
if ($obj === false) {
209209
// Entry no longer exists in APC, so clear it from the cache array
210210
parent::deleteCacheData($cellID);
211211
throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC');
212212
}
213-
if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->_cacheTime)) {
213+
if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
214214
$this->__destruct();
215215
throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC');
216216
}
217217
}
218218
}
219-
$this->_cachePrefix = $newCachePrefix;
219+
$this->cachePrefix = $newCachePrefix;
220220
}
221221

222222
/**
@@ -226,18 +226,18 @@ public function copyCellCollection(PHPExcel_Worksheet $parent)
226226
*/
227227
public function unsetWorksheetCells()
228228
{
229-
if ($this->_currentObject !== null) {
230-
$this->_currentObject->detach();
231-
$this->_currentObject = $this->_currentObjectID = null;
229+
if ($this->currentObject !== null) {
230+
$this->currentObject->detach();
231+
$this->currentObject = $this->currentObjectID = null;
232232
}
233233

234234
// Flush the APC cache
235235
$this->__destruct();
236236

237-
$this->_cellCache = array();
237+
$this->cellCache = array();
238238

239239
// detach ourself from the worksheet, so that it can then delete this object successfully
240-
$this->_parent = null;
240+
$this->parent = null;
241241
}
242242

243243
/**
@@ -250,10 +250,10 @@ public function __construct(PHPExcel_Worksheet $parent, $arguments)
250250
{
251251
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
252252

253-
if ($this->_cachePrefix === null) {
254-
$baseUnique = $this->_getUniqueID();
255-
$this->_cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
256-
$this->_cacheTime = $cacheTime;
253+
if ($this->cachePrefix === null) {
254+
$baseUnique = $this->getUniqueID();
255+
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
256+
$this->cacheTime = $cacheTime;
257257

258258
parent::__construct($parent);
259259
}
@@ -266,7 +266,7 @@ public function __destruct()
266266
{
267267
$cacheList = $this->getCellList();
268268
foreach ($cacheList as $cellID) {
269-
apc_delete($this->_cachePrefix . $cellID . '.cache');
269+
apc_delete($this->cachePrefix . $cellID . '.cache');
270270
}
271271
}
272272

0 commit comments

Comments
 (0)