1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the ICanBoogie package. |
||
5 | * |
||
6 | * (c) Olivier Laviale <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace ICanBoogie\Storage\FileStorage\Adapter; |
||
13 | |||
14 | use ICanBoogie\Storage\FileStorage\Adapter; |
||
15 | |||
16 | /** |
||
17 | * Data is encoded and decoded with `serialize()` and `unserialize()`. |
||
18 | */ |
||
19 | class SerializeAdapter implements Adapter |
||
20 | { |
||
21 | /** |
||
22 | * @inheritdoc |
||
23 | */ |
||
24 | public function write(string $filename, $data): bool |
||
25 | { |
||
26 | return file_put_contents($filename, serialize($data)); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @inheritdoc |
||
31 | */ |
||
32 | public function read(string $filename) |
||
33 | { |
||
34 | return unserialize(file_get_contents($filename)); |
||
35 | } |
||
36 | } |
||
37 |