Passed
Push — master ( d95688...5c1276 )
by smiley
01:47
created
src/CacheOptionsTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\SimpleCache;
14 14
 
15
-trait CacheOptionsTrait{
15
+trait CacheOptionsTrait {
16 16
 
17 17
 	protected $cacheFilestorage = '';
18
-	protected $cacheSessionkey    = '_session_cache';
18
+	protected $cacheSessionkey = '_session_cache';
19 19
 
20 20
 }
Please login to merge, or discard this patch.
src/CacheOptions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,6 +18,6 @@
 block discarded – undo
18 18
  * @property string $cacheFilestorage
19 19
  * @property string $cacheSessionkey
20 20
  */
21
-class CacheOptions extends ImmutableSettingsAbstract{
21
+class CacheOptions extends ImmutableSettingsAbstract {
22 22
 	use CacheOptionsTrait;
23 23
 }
Please login to merge, or discard this patch.
src/Drivers/SessionCacheDriver.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use chillerlan\SimpleCache\CacheException;
16 16
 use chillerlan\Traits\ImmutableSettingsInterface;
17 17
 
18
-class SessionCacheDriver extends CacheDriverAbstract{
18
+class SessionCacheDriver extends CacheDriverAbstract {
19 19
 
20 20
 	/**
21 21
 	 * @var string
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @throws \chillerlan\SimpleCache\CacheException
31 31
 	 */
32
-	public function __construct(ImmutableSettingsInterface $options = null){
32
+	public function __construct(ImmutableSettingsInterface $options = null) {
33 33
 		parent::__construct($options);
34 34
 
35 35
 		$this->key = $this->options->cacheSessionkey;
36 36
 
37
-		if(!is_string($this->key) || empty($this->key)){
37
+		if (!is_string($this->key) || empty($this->key)) {
38 38
 			$msg = 'invalid session cache key';
39 39
 
40 40
 			$this->logger->error($msg);
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 
48 48
 	/** @inheritdoc */
49
-	public function get(string $key, $default = null){
49
+	public function get(string $key, $default = null) {
50 50
 
51
-		if(isset($_SESSION[$this->key][$key])){
51
+		if (isset($_SESSION[$this->key][$key])) {
52 52
 
53
-			if($_SESSION[$this->key][$key]['ttl'] === null || $_SESSION[$this->key][$key]['ttl'] > time()){
53
+			if ($_SESSION[$this->key][$key]['ttl'] === null || $_SESSION[$this->key][$key]['ttl'] > time()) {
54 54
 				return $_SESSION[$this->key][$key]['content'];
55 55
 			}
56 56
 
Please login to merge, or discard this patch.
src/Drivers/FileCacheDriver.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use chillerlan\Traits\ImmutableSettingsInterface;
17 17
 use FilesystemIterator, RecursiveDirectoryIterator, RecursiveIteratorIterator, stdClass;
18 18
 
19
-class FileCacheDriver extends CacheDriverAbstract{
19
+class FileCacheDriver extends CacheDriverAbstract {
20 20
 
21 21
 	/**
22 22
 	 * @var string
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @throws \chillerlan\SimpleCache\CacheException
32 32
 	 */
33
-	public function __construct(ImmutableSettingsInterface $options = null){
33
+	public function __construct(ImmutableSettingsInterface $options = null) {
34 34
 		parent::__construct($options);
35 35
 
36 36
 		$this->cachedir = rtrim($this->options->cacheFilestorage, '/\\').DIRECTORY_SEPARATOR;
37 37
 
38
-		if(!is_dir($this->cachedir)){
38
+		if (!is_dir($this->cachedir)) {
39 39
 			$msg = 'invalid cachedir "'.$this->cachedir.'"';
40 40
 
41 41
 			$this->logger->error($msg);
42 42
 			throw new CacheException($msg);
43 43
 		}
44 44
 
45
-		if(!is_writable($this->cachedir)){
45
+		if (!is_writable($this->cachedir)) {
46 46
 			$msg = 'cachedir is read-only. permissions?';
47 47
 
48 48
 			$this->logger->error($msg);
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	/** @inheritdoc */
55
-	public function get(string $key, $default = null){
55
+	public function get(string $key, $default = null) {
56 56
 		$filename = $this->getFilepath($key);
57 57
 
58
-		if(is_file($filename)){
58
+		if (is_file($filename)) {
59 59
 			$content = file_get_contents($filename);
60 60
 
61
-			if(!empty($content)){
61
+			if (!empty($content)) {
62 62
 				$data = unserialize($content);
63 63
 
64
-				if($data->ttl === null || $data->ttl > time()){
64
+				if ($data->ttl === null || $data->ttl > time()) {
65 65
 					return $data->content;
66 66
 				}
67 67
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		$file = $this->getFilepath($key);
79 79
 		$dir  = dirname($file);
80 80
 
81
-		if(!is_dir($dir)){
81
+		if (!is_dir($dir)) {
82 82
 			mkdir($dir, 0755, true);
83 83
 		}
84 84
 
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 		$data->ttl     = null;
87 87
 		$data->content = $value;
88 88
 
89
-		if($ttl !== null){
89
+		if ($ttl !== null) {
90 90
 			$data->ttl = time() + $ttl;
91 91
 		}
92 92
 
93 93
 		file_put_contents($file, serialize($data));
94 94
 
95
-		if(is_file($file)){
95
+		if (is_file($file)) {
96 96
 			return true;
97 97
 		}
98 98
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	public function delete(string $key):bool{
104 104
 		$filename = $this->getFilepath($key);
105 105
 
106
-		if(is_file($filename)){
106
+		if (is_file($filename)) {
107 107
 			return unlink($filename);
108 108
 		}
109 109
 
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 
113 113
 	/** @inheritdoc */
114 114
 	public function clear():bool{
115
-		$iterator = new RecursiveDirectoryIterator($this->cachedir, FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS);
115
+		$iterator = new RecursiveDirectoryIterator($this->cachedir, FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS);
116 116
 		$return   = [];
117 117
 
118
-		foreach(new RecursiveIteratorIterator($iterator) as $path){
118
+		foreach (new RecursiveIteratorIterator($iterator) as $path) {
119 119
 
120 120
 			// skip files the parent directory - cache files are only under /a/ab/[hash]
121
-			if(strpos(str_replace($this->cachedir, '', $path), DIRECTORY_SEPARATOR) === false){
121
+			if (strpos(str_replace($this->cachedir, '', $path), DIRECTORY_SEPARATOR) === false) {
122 122
 				continue;
123 123
 			}
124 124
 
Please login to merge, or discard this patch.