1 | <?php |
||
15 | class TemporaryFile implements ICache |
||
16 | { |
||
17 | use injector; |
||
18 | |||
19 | /** |
||
20 | * @var Container キャッシュ依存コンテナ |
||
21 | */ |
||
22 | private $cacheContainer; |
||
23 | |||
24 | /** |
||
25 | * @var string キャッシュ接頭辞 |
||
26 | */ |
||
27 | private $cachePrefix; |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | public function __construct(Container $cacheContainer) |
||
33 | { |
||
34 | $this->cacheContainer = $cacheContainer; |
||
35 | $this->cachePrefix = $this->cacheContainer->cachePrefix . '.' . $this->cacheContainer->classPrefix . '.'; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | 4 | public function add($key, $data, $ttl = 0, $overwrite = false): bool |
|
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | 4 | public function get($key) |
|
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | 1 | public function delete($key): bool |
|
122 | { |
||
123 | 1 | if (!$this->isAvailableCacheLibrary()) { |
|
124 | return false; |
||
125 | } |
||
126 | 1 | $key = $this->cachePrefix . $key; |
|
127 | 1 | $result = false; |
|
128 | |||
129 | 1 | $file = new File($this->cacheContainer->cacheDir . '/' . $key . '.cache'); |
|
130 | 1 | if ($file->isWritable()) { |
|
131 | 1 | $result = $file->delete(); |
|
132 | 1 | if ($result) { |
|
133 | 1 | $this->logger->info("Execute cache cleared: " . $key); |
|
134 | } else { |
||
135 | $this->logger->warn("Failed to clear cache: " . $key); |
||
136 | } |
||
137 | } else { |
||
138 | $this->logger->warn("Failed to clear cache: " . $key); |
||
139 | } |
||
140 | |||
141 | 1 | return $result; |
|
142 | } |
||
143 | |||
144 | /** |
||
145 | * {@inheritdoc} |
||
146 | */ |
||
147 | 1 | public function clear(): bool |
|
148 | { |
||
149 | 1 | if (!$this->isAvailableCacheLibrary()) { |
|
150 | return false; |
||
151 | } |
||
152 | 1 | $dir = new File($this->cacheContainer->cacheDir); |
|
153 | 1 | $result = true; |
|
154 | |||
155 | 1 | if ($dir->isReadable()) { |
|
156 | 1 | $iterator = $this->cacheContainer->ioContainer->fileIterator->getIterator($dir->getFilePath()); |
|
157 | 1 | foreach ($iterator as $filepath => $fileObject) { |
|
158 | 1 | if (strpos($filepath, $this->cachePrefix, 0) !== false) { |
|
159 | try { |
||
160 | 1 | $file = new File($filepath); |
|
161 | 1 | if ($file->isWritable()) { |
|
162 | 1 | if ($file->delete()) { |
|
163 | 1 | $this->logger->info("Execute cache cleared: " . $this->cachePrefix . "*"); |
|
164 | } else { |
||
165 | $this->logger->warn("Failed to clear cache: " . $this->cachePrefix . "*"); |
||
166 | $result = false; |
||
167 | } |
||
168 | } else { |
||
169 | $result = false; |
||
170 | } |
||
171 | } catch (IOException $e) { |
||
172 | $this->logger->warn($e->getMessage()); |
||
173 | 1 | $result = false; |
|
174 | } |
||
175 | } |
||
176 | } |
||
177 | } else { |
||
178 | $this->logger->warn("Can't read directory:" . $dir->getFilePath()); |
||
179 | $result = false; |
||
180 | } |
||
181 | |||
182 | 1 | return $result; |
|
183 | } |
||
184 | |||
185 | /** |
||
186 | * キャッシュライブラリが使用可能か検査する |
||
187 | * @return bool 使用可能でtrue |
||
188 | */ |
||
189 | 4 | private function isAvailableCacheLibrary(): bool |
|
199 | } |
||
200 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.