@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | final class FileVarExportHandler extends BaseHandler |
17 | 17 | { |
18 | - private string $path = FRAMEWORK_STORAGE_PATH . 'cache'; |
|
18 | + private string $path = FRAMEWORK_STORAGE_PATH . 'cache'; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * {@inheritDoc} |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | /** |
37 | 37 | * {@inheritDoc} |
38 | - * |
|
39 | - * @param array|bool|float|int|object|string|null $value |
|
38 | + * |
|
39 | + * @param array|bool|float|int|object|string|null $value |
|
40 | 40 | */ |
41 | 41 | public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool |
42 | 42 | { |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | |
60 | 60 | /** |
61 | 61 | * {@inheritDoc} |
62 | - * |
|
63 | - * @return array|bool|float|int|object|string|null |
|
62 | + * |
|
63 | + * @return array|bool|float|int|object|string|null |
|
64 | 64 | */ |
65 | 65 | public function get(string $key, mixed $default = null): mixed |
66 | 66 | { |
67 | - return @include $this->path . "/{$key}"; |
|
68 | - } |
|
67 | + return @include $this->path . "/{$key}"; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * {@inheritDoc} |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function delete(string $key): bool |
98 | 98 | { |
99 | - return @unlink($this->path . "/{$key}"); |
|
99 | + return @unlink($this->path . "/{$key}"); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -112,21 +112,21 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function clear(): bool |
114 | 114 | { |
115 | - if (! is_dir($this->path)) { |
|
116 | - return false; |
|
117 | - } |
|
118 | - |
|
119 | - $files = glob($this->path . '/*'); |
|
120 | - foreach ($files as $file) { |
|
121 | - if (is_file($file)) { |
|
122 | - unlink($file); |
|
123 | - } elseif (is_dir($file)) { |
|
124 | - $this->clear($file); |
|
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - return rmdir($this->path); |
|
129 | - } |
|
115 | + if (! is_dir($this->path)) { |
|
116 | + return false; |
|
117 | + } |
|
118 | + |
|
119 | + $files = glob($this->path . '/*'); |
|
120 | + foreach ($files as $file) { |
|
121 | + if (is_file($file)) { |
|
122 | + unlink($file); |
|
123 | + } elseif (is_dir($file)) { |
|
124 | + $this->clear($file); |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + return rmdir($this->path); |
|
129 | + } |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * {@inheritDoc} |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | final class FileVarExportHandler extends BaseHandler |
17 | 17 | { |
18 | - private string $path = FRAMEWORK_STORAGE_PATH . 'cache'; |
|
18 | + private string $path = FRAMEWORK_STORAGE_PATH.'cache'; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * {@inheritDoc} |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * {@inheritDoc} |
30 | 30 | */ |
31 | - public function init(array $config = []): bool |
|
31 | + public function init(array $config = [ ]): bool |
|
32 | 32 | { |
33 | 33 | return true; |
34 | 34 | } |
@@ -38,21 +38,21 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param array|bool|float|int|object|string|null $value |
40 | 40 | */ |
41 | - public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool |
|
41 | + public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool |
|
42 | 42 | { |
43 | 43 | $value = var_export($value, true); |
44 | 44 | |
45 | 45 | // Écrire d'abord dans le fichier temporaire pour assurer l'atomicité |
46 | - $tmp = $this->path . "/{$key}." . uniqid('', true) . '.tmp'; |
|
47 | - file_put_contents($tmp, '<?php return ' . $value . ';', LOCK_EX); |
|
46 | + $tmp = $this->path."/{$key}.".uniqid('', true).'.tmp'; |
|
47 | + file_put_contents($tmp, '<?php return '.$value.';', LOCK_EX); |
|
48 | 48 | |
49 | - return rename($tmp, $this->path . "/{$key}"); |
|
49 | + return rename($tmp, $this->path."/{$key}"); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * {@inheritDoc} |
54 | 54 | */ |
55 | - public function setMultiple(iterable $values, null|DateInterval|int $ttl = null): bool |
|
55 | + public function setMultiple(iterable $values, null | DateInterval | int $ttl = null): bool |
|
56 | 56 | { |
57 | 57 | return true; |
58 | 58 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function get(string $key, mixed $default = null): mixed |
66 | 66 | { |
67 | - return @include $this->path . "/{$key}"; |
|
67 | + return @include $this->path."/{$key}"; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function getMultiple(iterable $keys, mixed $default = null): iterable |
74 | 74 | { |
75 | - return []; |
|
75 | + return [ ]; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function delete(string $key): bool |
98 | 98 | { |
99 | - return @unlink($this->path . "/{$key}"); |
|
99 | + return @unlink($this->path."/{$key}"); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function clear(): bool |
114 | 114 | { |
115 | - if (! is_dir($this->path)) { |
|
115 | + if (!is_dir($this->path)) { |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - $files = glob($this->path . '/*'); |
|
119 | + $files = glob($this->path.'/*'); |
|
120 | 120 | foreach ($files as $file) { |
121 | 121 | if (is_file($file)) { |
122 | 122 | unlink($file); |