mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 23:17:02 +03:00
Bugfixes and more conversions to PHP 7
This commit is contained in:
parent
2cada68f41
commit
3a7ec4ecb0
100 changed files with 238 additions and 992 deletions
|
|
@ -28,13 +28,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
*/
|
||||
private $sKeyPrefix;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
* @param string $sCacheFolder
|
||||
* @param string $sKeyPrefix = ''
|
||||
*/
|
||||
private function __construct($sCacheFolder, $sKeyPrefix = '')
|
||||
private function __construct(string $sCacheFolder, string $sKeyPrefix = '')
|
||||
{
|
||||
$this->sCacheFolder = $sCacheFolder;
|
||||
$this->sCacheFolder = rtrim(trim($this->sCacheFolder), '\\/').'/';
|
||||
|
|
@ -51,33 +45,18 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sCacheFolder
|
||||
* @param string $sKeyPrefix = ''
|
||||
*
|
||||
* @return \MailSo\Cache\Drivers\File
|
||||
*/
|
||||
public static function NewInstance($sCacheFolder, $sKeyPrefix = '')
|
||||
public static function NewInstance(string $sCacheFolder, string $sKeyPrefix = '') : self
|
||||
{
|
||||
return new self($sCacheFolder, $sKeyPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
* @param string $sValue
|
||||
*/
|
||||
public function Set($sKey, $sValue) : bool
|
||||
public function Set(string $sKey, string $sValue) : bool
|
||||
{
|
||||
$sPath = $this->generateCachedFileName($sKey, true);
|
||||
return '' === $sPath ? false : false !== \file_put_contents($sPath, $sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function Get($sKey)
|
||||
public function Get(string $sKey) : string
|
||||
{
|
||||
$sValue = '';
|
||||
$sPath = $this->generateCachedFileName($sKey);
|
||||
|
|
@ -89,12 +68,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
return \is_string($sValue) ? $sValue : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function Delete($sKey)
|
||||
public function Delete(string $sKey) : void
|
||||
{
|
||||
$sPath = $this->generateCachedFileName($sKey);
|
||||
if ('' !== $sPath && \file_exists($sPath))
|
||||
|
|
@ -103,12 +77,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iTimeToClearInHours = 24
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function GC($iTimeToClearInHours = 24)
|
||||
public function GC(int $iTimeToClearInHours = 24) : bool
|
||||
{
|
||||
if (0 < $iTimeToClearInHours)
|
||||
{
|
||||
|
|
@ -119,13 +88,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sKey
|
||||
* @param bool $bMkDir = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateCachedFileName($sKey, $bMkDir = false)
|
||||
private function generateCachedFileName(string $sKey, bool $bMkDir = false) : string
|
||||
{
|
||||
$sFilePath = '';
|
||||
if (3 < \strlen($sKey))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue