id()
id() : string
The stable identifier recorded in a frame header.
Returns
string —A short lowercase token such as "zstd", "gzip" or "none".
Brotli through the `brotli` binary, for hosts without `ext-brotli`.
The reason to have it is reading, not writing. Brotli reaches the highest ratio Strata measured
on Drupal-shaped data, so a site with the extension may well have a bucket full of brotli frames;
without this, moving that site to a host whose PHP was built without ext-brotli makes every one
of those frames unreadable and the backup stops being a backup. brotli ships in the base
repositories of every mainstream distribution, so the binary is usually already there.
Like every PipeCodec it is registered for reading and bulk work only. It also loses the write path on merit: brotli at its top quality is 0.7 MB/s before a process spawn is added.
The CLI's -D takes a raw LZ77 dictionary, which is what brotli_compress() takes fourth, so
the two produce and read each other's dictionary-coded frames.
levels() : array{min: int, max: int, default: int, fast: int, dense: int}
The compression levels this codec accepts.
The usable range, the default, the level to use on the flush path where throughput matters, and the level to use during compaction where ratio matters.
__construct(string|null $binaryPath = null, string|null $scratchDirectory = null) : mixed
Constructs the codec.
| string|null | $binaryPath | An explicit path to the binary, or NULL to search PATH and the common directories. |
| string|null | $scratchDirectory | Directory for batch scratch files, or NULL for the system temporary directory. |
compress(string $data, ?int $level = null, ?string $dictionary = null) : string
Compresses a buffer.
| string | $data | The bytes to compress. An empty string compresses to an empty string, so that an absent payload never becomes a non-empty frame. |
| ?int | $level | A level within CompressionCodecInterface::levels(), or NULL for the default. |
| ?string | $dictionary | Raw dictionary bytes, or NULL. Ignored by codecs that report no dictionary support, so a caller never has to branch on it. |
The compressed bytes.
compressBatch(list$buffers, int|null $level = null, string|null $dictionary = null) : list<string>
Compresses many buffers in one process.
| list |
$buffers | The buffers to compress, in order. |
| int|null | $level | A level within PipeCodec::levels(), or NULL for the default. |
| string|null | $dictionary | Raw dictionary bytes, or NULL. |
When the codec is unavailable, or the binary fails.
The compressed buffers, in the same order.
decompressBatch(list$buffers, string|null $dictionary = null) : list<string>
Decompresses many buffers in one process.
| list |
$buffers | The buffers to decompress, in order. |
| string|null | $dictionary | The same dictionary bytes used to compress, or NULL. |
When the codec is unavailable, or the binary fails.
The original buffers, in the same order.
arguments(bool $compressing, int $level, string|null $dictionaryPath) : list<string>
The flags one invocation runs with, before the input paths.
| bool | $compressing | TRUE to compress, FALSE to decompress. |
| int | $level | A level already brought into range by PipeCodec::clamp(). |
| string|null | $dictionaryPath | Where the dictionary was written, or NULL when there is none. |
The arguments, without the binary itself.