MediaWiki  1.34.0
EasyDeflate.php
Go to the documentation of this file.
1 <?php
24 class EasyDeflate {
25 
33  public static function isDeflated( $data ) {
34  return substr( $data, 0, 11 ) === 'rawdeflate,';
35  }
36 
56  public static function inflate( $data ) {
57  if ( !self::isDeflated( $data ) ) {
58  throw new InvalidArgumentException( 'Data does not begin with deflated prefix' );
59  }
60  $deflated = base64_decode( substr( $data, 11 ), true );
61  if ( $deflated === false ) {
62  return StatusValue::newFatal( 'easydeflate-invaliddeflate' );
63  }
64  Wikimedia\suppressWarnings();
65  $inflated = gzinflate( $deflated );
66  Wikimedia\restoreWarnings();
67  if ( $inflated === false ) {
68  return StatusValue::newFatal( 'easydeflate-invaliddeflate' );
69  }
70  return StatusValue::newGood( $inflated );
71  }
72 }
StatusValue\newFatal
static newFatal( $message,... $parameters)
Factory function for fatal errors.
Definition: StatusValue.php:69
EasyDeflate
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
Definition: EasyDeflate.php:24
EasyDeflate\isDeflated
static isDeflated( $data)
Whether the content is deflated.
Definition: EasyDeflate.php:33
EasyDeflate\inflate
static inflate( $data)
For content that has been compressed with deflate in the client, try to uncompress it with inflate.
Definition: EasyDeflate.php:56
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81