Oihana PHP

getPharCompressionType.php

Table of Contents

Functions

getPharCompressionType()  : int
Returns the corresponding Phar compression constant for a given compression type.

Functions

getPharCompressionType()

Returns the corresponding Phar compression constant for a given compression type.

getPharCompressionType(string $compression) : int

This function maps a compression type (e.g., gzip, bzip2, or none) to the appropriate Phar compression constant (e.g., Phar::GZ, Phar::BZ2, Phar::NONE).

It is useful when setting or detecting compression in Phar archives programmatically.

Parameters
$compression : string

The compression type to resolve. Must be one of the values defined in CompressionType.

Tags
throws
UnsupportedCompressionException

If the given compression type is not supported.

example
use oihana\files\phar\getPharCompressionType;
use oihana\files\enums\CompressionType;

$compression = CompressionType::GZIP;
$pharConstant = getPharCompressionType($compression);

echo $pharConstant; // Outputs: 4096 (Phar::GZ)
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
int

The Phar compression constant (Phar::GZ, Phar::BZ2, or Phar::NONE).


        
On this page

Search results