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