| 1 |
<?php |
| 2 |
/** |
| 3 |
* The Compressible contract for different browser compression strategies. |
| 4 |
* |
| 5 |
* @package SolidWP\Performance |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace SolidWP\Performance\Page_Cache\Compression\Contracts; |
| 11 |
|
| 12 |
use SolidWP\Performance\Page_Cache\Compression\Exceptions\CompressionFailedException; |
| 13 |
|
| 14 |
/** |
| 15 |
* @internal |
| 16 |
*/ |
| 17 |
interface Compressible { |
| 18 |
|
| 19 |
/** |
| 20 |
* Whether the current host has the appropriate PHP extensions to |
| 21 |
* support this compression algorithm. |
| 22 |
* |
| 23 |
* @return bool |
| 24 |
*/ |
| 25 |
public function supported(): bool; |
| 26 |
|
| 27 |
/** |
| 28 |
* Whether this type of compression is enabled. |
| 29 |
* |
| 30 |
* @return bool |
| 31 |
*/ |
| 32 |
public function enabled(): bool; |
| 33 |
|
| 34 |
/** |
| 35 |
* Get the file extension for this type of compression. |
| 36 |
* |
| 37 |
* @return string |
| 38 |
*/ |
| 39 |
public function extension(): string; |
| 40 |
|
| 41 |
/** |
| 42 |
* Return the content-encoding header value, if any. |
| 43 |
* |
| 44 |
* @example gzip, br, zstd etc. |
| 45 |
* |
| 46 |
* @return string |
| 47 |
*/ |
| 48 |
public function encoding(): string; |
| 49 |
|
| 50 |
/** |
| 51 |
* Send Content-Encoding headers with the strategy's encoding. |
| 52 |
* |
| 53 |
* @return void |
| 54 |
*/ |
| 55 |
public function send_headers(): void; |
| 56 |
|
| 57 |
/** |
| 58 |
* Compress content. |
| 59 |
* |
| 60 |
* @param string $content The content to compress. |
| 61 |
* |
| 62 |
* @throws CompressionFailedException When the strategy fails to compress the content. |
| 63 |
* |
| 64 |
* @return string |
| 65 |
*/ |
| 66 |
public function compress( string $content ): string; |
| 67 |
} |
| 68 |
|