ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
DeflateCompression.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 {
28  private const LEVEL = 9;
29 
33  public function compress(string $data): string
34  {
35  $compressed = \gzdeflate($data, self::LEVEL);
36  if ($compressed === false) {
37  throw new CompressionFailure();
38  }
39  return $compressed;
40  }
41 
45  public function decompress(string $data): string
46  {
47  $decompressed = \gzinflate($data);
48  if ($decompressed === false) {
49  throw new CompressionFailure();
50  }
51 
52  return $decompressed;
53  }
54 }