Skip to content
Permalink
Browse files

Changing return types

read now returns empty string instead of false when read method returns an empty value.
write, destroy and gc will return boolean type
  • Loading branch information...
phpnut committed Dec 22, 2015
1 parent 776c128 commit dd11c630692d03f35aecd5d9b70a8d555cab3d9c
@@ -52,7 +52,11 @@ public function close() {
* @return mixed The value of the key or false if it does not exist
*/
public function read($id) {
return Cache::read($id, Configure::read('Session.handler.config'));
$data = Cache::read($id, Configure::read('Session.handler.config'));
if(empty($data)){
return '';
}
return $data;
}
/**
@@ -63,7 +67,7 @@ public function read($id) {
* @return bool True for successful write, false otherwise.
*/
public function write($id, $data) {
return Cache::write($id, $data, Configure::read('Session.handler.config'));
return (bool)Cache::write($id, $data, Configure::read('Session.handler.config'));
}
/**
@@ -73,7 +77,7 @@ public function write($id, $data) {
* @return bool True for successful delete, false otherwise.
*/
public function destroy($id) {
return Cache::delete($id, Configure::read('Session.handler.config'));
return (bool)Cache::delete($id, Configure::read('Session.handler.config'));
}
/**
@@ -83,7 +87,7 @@ public function destroy($id) {
* @return bool Success
*/
public function gc($expires = null) {
return Cache::gc(Configure::read('Session.handler.config'), $expires);
return (bool)Cache::gc(Configure::read('Session.handler.config'), $expires);
}
}
@@ -93,10 +93,10 @@ public function read($id) {
));
if (empty($row[$this->_model->alias]['data'])) {
return false;
return '';
}
return $row[$this->_model->alias]['data'];
return (string)$row[$this->_model->alias]['data'];
}
/**
@@ -123,9 +123,9 @@ public function write($id, $data) {
'counterCache' => false
);
try {
return $this->_model->save($record, $options);
return (bool)$this->_model->save($record, $options);
} catch (PDOException $e) {
return $this->_model->save($record, $options);
return (bool)$this->_model->save($record, $options);
}
}
@@ -136,7 +136,8 @@ public function write($id, $data) {
* @return bool True for successful delete, false otherwise.
*/
public function destroy($id) {
return $this->_model->delete($id);
return true;
return (bool)$this->_model->delete($id);
}
/**
@@ -151,7 +152,8 @@ public function gc($expires = null) {
} else {
$expires = time() - $expires;
}
return $this->_model->deleteAll(array($this->_model->alias . ".expires <" => $expires), false, false);
$this->_model->deleteAll(array($this->_model->alias . ".expires <" => $expires), false, false);
return true;
}
}

0 comments on commit dd11c63

Please sign in to comment.
You can’t perform that action at this time.