1: <?php
2: require_once 'iCompression.php';
3: /**
4: * Use the Lzf Comperssion
5: *
6: * @package Compression
7: * @filesource LzfCompression.php
8: *
9: * @author Cyril Nicodème
10: * @version 0.1
11: *
12: * @since 15/07/2008
13: *
14: * @license GNU/GPL
15: */
16: class LzfCompression implements iCompression
17: {
18: /**
19: * Constructor
20: * Used to check if the extensions exists
21: *
22: * @throws Exception
23: */
24: public function __construct ()
25: {
26: if (!function_exists ('lzf_compress'))
27: throw new Exception ('Lzf extensions is missing');
28: }
29:
30: /**
31: * Compress the given value to the specific compression
32: *
33: * @param String $sValue
34: * @param String $iLevel (Optionnal) : Between 0 and 9
35: *
36: * @return String
37: *
38: * @throws Exception
39: */
40: public function compress ($sValue, $iLevel = null)
41: {
42: if (!is_string ($sValue))
43: throw new Exception ('Invalid first argument, must be a string');
44:
45: return lzf_compress ($sValue);
46: }
47:
48: /**
49: * Decompress the given value with the specific compression
50: *
51: * @param String $sValue
52: *
53: * @return String
54: *
55: * @throws Exception
56: */
57: public function decompress ($sValue)
58: {
59: if (!is_string ($sValue))
60: throw new Exception ('Invalid first argument, must be a string');
61:
62: return lzf_decompress ($sValue);
63: }
64: }
65: