PHP Class Contao\ZipReader

Usage: $zip = new ZipReader('test.zip'); while ($zip->next()) { echo $zip->->file_name; }
Show file Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$arrFiles array File list
$arrHeader array Archive header
$resFile resource File handle
$strFile string File name

Public Methods

Method Description
__construct ( string $strFile ) Open the archive and return the file handle
__destruct ( ) Close the file handle
__get ( string $strKey ) : mixed | null Return a property of the archive header or the current file
current ( ) : array Return the current file as array
first ( ) : ZipReader Go to the first file of the archive
getFile ( string $strName ) : boolean Set the internal pointer to a particular file
getFileList ( ) : array Return a list of all files in the archive
last ( ) : ZipReader Go to the last file of the archive
next ( ) : ZipReader | boolean Go to the next file of the archive
prev ( ) : ZipReader | boolean Go to the previous file of the archive
reset ( ) : ZipReader Reset the archive
unzip ( ) : string Unzip the current file and return its contents as string

Protected Methods

Method Description
decToUnix ( integer $intTime, integer $intDate ) : integer Calculate the Unix timestamp from two hexadecimal values
readCentralDirectory ( ) : array Return a list of all files in the archive

Method Details

__construct() public method

Open the archive and return the file handle
public __construct ( string $strFile )
$strFile string The file path

__destruct() public method

Close the file handle
public __destruct ( )

__get() public method

Return a property of the archive header or the current file
public __get ( string $strKey ) : mixed | null
$strKey string The property name
return mixed | null The property value or null

current() public method

Return the current file as array
public current ( ) : array
return array The current file array

decToUnix() protected method

Calculate the Unix timestamp from two hexadecimal values
protected decToUnix ( integer $intTime, integer $intDate ) : integer
$intTime integer The time integer
$intDate integer The date integer
return integer The Unix timestamp

first() public method

Go to the first file of the archive
public first ( ) : ZipReader
return ZipReader The object instance

getFile() public method

Set the internal pointer to a particular file
public getFile ( string $strName ) : boolean
$strName string The file name
return boolean True if the file was found

getFileList() public method

Return a list of all files in the archive
public getFileList ( ) : array
return array The files array

last() public method

Go to the last file of the archive
public last ( ) : ZipReader
return ZipReader The object instance

next() public method

Go to the next file of the archive
public next ( ) : ZipReader | boolean
return ZipReader | boolean The object instance or false if there is no next file

prev() public method

Go to the previous file of the archive
public prev ( ) : ZipReader | boolean
return ZipReader | boolean The object instance or false if there is no previous file

readCentralDirectory() protected method

Return a list of all files in the archive
protected readCentralDirectory ( ) : array
return array The files array

reset() public method

Reset the archive
public reset ( ) : ZipReader
return ZipReader The object instance

unzip() public method

Unzip the current file and return its contents as string
public unzip ( ) : string
return string The file content

Property Details

$arrFiles protected property

File list
protected array $arrFiles
return array

$arrHeader protected property

Archive header
protected array $arrHeader
return array

$resFile protected property

File handle
protected resource $resFile
return resource

$strFile protected property

File name
protected string $strFile
return string