1: <?php
2: require_once 'iCompression.php';
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16: class BzCompression implements iCompression
17: {
18: 19: 20: 21: 22: 23:
24: public function __construct ()
25: {
26: if (!function_exists ('bzcompress'))
27: throw new Exception ('Bz extensions is missing');
28: }
29:
30: 31: 32: 33: 34: 35: 36: 37: 38: 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: if (isset ($iLevel) && !is_int ($iLevel))
46: throw new Exception ('Invalid second argument, must be an int');
47:
48: if ($iValue < 0 || $iValue > 9)
49: throw new Exception ('Invalid second argument, must be between 0 and 9');
50:
51: return bzcompress ($sValue, $iLevel);
52: }
53:
54: 55: 56: 57: 58: 59: 60: 61: 62:
63: public function decompress ($sValue)
64: {
65: if (!is_string ($sValue))
66: throw new Exception ('Invalid first argument, must be a string');
67:
68: return bzdecompress ($sValue);
69: }
70: }
71: