blob: 7fce838a4f744188ba65685e6e7f81eda4d2d0b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?php
namespace Safe;
use Safe\Exceptions\LzfException;
/**
* lzf_compress compresses the given
* data string using LZF encoding.
*
* @param string $data The string to compress.
* @return string Returns the compressed data.
* @throws LzfException
*
*/
function lzf_compress(string $data): string
{
error_clear_last();
$result = \lzf_compress($data);
if ($result === false) {
throw LzfException::createFromPhpError();
}
return $result;
}
/**
* lzf_compress decompresses the given
* data string containing lzf encoded data.
*
* @param string $data The compressed string.
* @return string Returns the decompressed data.
* @throws LzfException
*
*/
function lzf_decompress(string $data): string
{
error_clear_last();
$result = \lzf_decompress($data);
if ($result === false) {
throw LzfException::createFromPhpError();
}
return $result;
}
|