ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DeflateCompression.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27{
31 private const LEVEL = 9;
32
36 public function compress(string $data): string
37 {
38 $compressed = \gzdeflate($data, self::LEVEL);
39 if ($compressed === false) {
40 throw new CompressionFailure();
41 }
42 return $compressed;
43 }
44
48 public function decompress(string $data): string
49 {
50 $decompressed = \gzinflate($data);
51 if ($decompressed === false) {
52 throw new CompressionFailure();
53 }
54
55 return $decompressed;
56 }
57}