1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Library for confirmation tokens. |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/php-confirmator |
6
|
|
|
* @package php-confirmator |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hiqdev\php\confirmator; |
12
|
|
|
|
13
|
|
|
use yii\base\ErrorException; |
14
|
|
|
|
15
|
|
|
class FileStorage implements StorageInterface |
16
|
|
|
{ |
17
|
3 |
|
public $path; |
18
|
|
|
|
19
|
3 |
|
public function __construct($path = null) |
20
|
3 |
|
{ |
21
|
|
|
$this->path = $path; |
22
|
3 |
|
} |
23
|
|
|
|
24
|
3 |
|
protected function getFullPath($name) |
25
|
|
|
{ |
26
|
|
|
return $this->path . '/' . $name[0] . '/' . $name; |
27
|
2 |
|
} |
28
|
|
|
|
29
|
2 |
|
public function has($name) |
30
|
|
|
{ |
31
|
|
|
return is_file($this->getFullPath($name)); |
32
|
2 |
|
} |
33
|
|
|
|
34
|
2 |
|
public function get($name) |
35
|
|
|
{ |
36
|
2 |
|
$path = $this->getFullPath($name); |
37
|
|
|
|
38
|
|
|
return is_file($path) ? file_get_contents($this->getFullPath($name)) : null; |
39
|
3 |
|
} |
40
|
|
|
|
41
|
3 |
|
public function set($name, $text) |
42
|
3 |
|
{ |
43
|
3 |
|
$path = $this->getFullPath($name); |
44
|
3 |
|
$dir = dirname($path); |
45
|
|
|
if (!is_dir($dir)) { |
46
|
|
|
try { |
47
|
3 |
|
$success = mkdir($dir, 0755, true); |
48
|
|
|
} catch (\Throwable $e) { |
|
|
|
|
49
|
|
|
$success = false; |
50
|
|
|
} |
51
|
|
|
if (!$success) { |
52
|
|
|
throw new \Exception('Could not create storage in ' . $dir); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
try { |
57
|
|
|
$success = file_put_contents($path, $text); |
58
|
|
|
} catch (\Throwable $e) { |
|
|
|
|
59
|
|
|
$success = false; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if ($success === false) { |
63
|
|
|
throw new \Exception('Failed write file: ' . $path); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return $success; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function remove($name) |
70
|
|
|
{ |
71
|
|
|
$path = $this->getFullPath($name); |
72
|
|
|
|
73
|
|
|
return unlink($path); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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.