1 | <?php |
||
16 | class FileStorage implements StorageInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $dir; |
||
22 | |||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | protected $gcProbability; |
||
27 | |||
28 | /** |
||
29 | * @const string |
||
30 | */ |
||
31 | const FILE_SUFFIX = '.phpsst'; |
||
32 | |||
33 | /** |
||
34 | * FileStorage constructor. |
||
35 | * @param string $dir |
||
36 | * @param int $gcProbability |
||
37 | */ |
||
38 | 8 | public function __construct($dir, $gcProbability) |
|
52 | |||
53 | /** |
||
54 | * @param Password $password |
||
55 | * @param bool $allowOverwrite |
||
56 | */ |
||
57 | 7 | public function store(Password $password, $allowOverwrite = false) |
|
65 | |||
66 | /** |
||
67 | * @param $key |
||
68 | * @return Password|null |
||
69 | */ |
||
70 | 3 | public function get($key) |
|
93 | |||
94 | /** |
||
95 | * @param Password $password |
||
96 | */ |
||
97 | 2 | public function delete(Password $password) |
|
101 | |||
102 | /** |
||
103 | */ |
||
104 | 5 | protected function garbageCollection() |
|
119 | |||
120 | /** |
||
121 | * @param Password $password |
||
122 | */ |
||
123 | 6 | protected function writeFile(Password $password) |
|
140 | |||
141 | /** |
||
142 | * @param Password $password |
||
143 | * @return string |
||
144 | */ |
||
145 | 3 | protected function getFileName(Password $password) |
|
149 | |||
150 | /** |
||
151 | * @param string $key |
||
152 | * @return string |
||
153 | */ |
||
154 | 3 | protected function getFileNameFromKey($key) |
|
158 | } |
||
159 |