\PhpOffice\PhpWord\SharedZipArchive

ZipArchive wrapper

Wraps zip archive functionality of PHP ZipArchive and PCLZip. PHP ZipArchive properties and methods are bypassed and used as the model for the PCLZip emulation. Only needed PHP ZipArchive features are implemented.

Summary

Methods
Properties
Constants
__construct()
__call()
open()
close()
extractTo()
getFromName()
pclzipAddFile()
pclzipAddFromString()
pclzipExtractTo()
pclzipGetFromName()
pclzipGetNameIndex()
pclzipLocateName()
addFile()
addFromString()
getNameIndex()
locateName()
$numFiles
$filename
CREATE
OVERWRITE
No protected methods found
No protected properties found
N/A
No private methods found
$tempDir
$zip
$usePclzip
N/A

Constants

CREATE

CREATE = 1

OVERWRITE

OVERWRITE = 8

Properties

$numFiles

$numFiles : integer

Number of files (emulate ZipArchive::$numFiles)

Type

integer

$filename

$filename : string

Archive filename (emulate ZipArchive::$filename)

Type

string

$tempDir

$tempDir : string

Temporary storage directory

Type

string

$zip

$zip : \ZipArchive|\PclZip

Internal zip archive object

Type

\ZipArchive|\PclZip

$usePclzip

$usePclzip : boolean

Use PCLZip (default behaviour)

Type

boolean

Methods

__construct()

__construct() 

Create new instance

__call()

__call(mixed  $function, mixed  $args) : mixed

Catch function calls: pass to ZipArchive or PCLZip

call_user_func_array can only used for public function, hence the public in all pcl... methods

Parameters

mixed $function
mixed $args

Returns

mixed

open()

open(string  $filename, integer  $flags = null) : boolean

Open a new zip archive

Parameters

string $filename

The file name of the ZIP archive to open

integer $flags

The mode to use to open the archive

Returns

boolean

close()

close() : boolean

Close the active archive

Throws

\PhpOffice\PhpWord\Exception\Exception

Returns

boolean

extractTo()

extractTo(string  $destination, string|array  $entries = null) : boolean

Extract the archive contents (emulate \ZipArchive)

Parameters

string $destination
string|array $entries

Returns

boolean

getFromName()

getFromName(string  $filename) : string

Extract file from archive by given file name (emulate \ZipArchive)

Parameters

string $filename

Filename for the file in zip archive

Returns

string —

$contents File string contents

pclzipAddFile()

pclzipAddFile(string  $filename, string  $localname = null) : boolean

Add a new file to the zip archive (emulate \ZipArchive)

Parameters

string $filename

Directory/Name of the file to add to the zip archive

string $localname

Directory/Name of the file added to the zip

Returns

boolean

pclzipAddFromString()

pclzipAddFromString(string  $localname, string  $contents) : boolean

Add a new file to the zip archive from a string of raw data (emulate \ZipArchive)

Parameters

string $localname

Directory/Name of the file to add to the zip archive

string $contents

String of data to add to the zip archive

Returns

boolean

pclzipExtractTo()

pclzipExtractTo(string  $destination, string|array  $entries = null) : boolean

Extract the archive contents (emulate \ZipArchive)

Parameters

string $destination
string|array $entries

Returns

boolean

pclzipGetFromName()

pclzipGetFromName(string  $filename) : string

Extract file from archive by given file name (emulate \ZipArchive)

Parameters

string $filename

Filename for the file in zip archive

Returns

string —

$contents File string contents

pclzipGetNameIndex()

pclzipGetNameIndex(integer  $index) : string|boolean

Returns the name of an entry using its index (emulate \ZipArchive)

Parameters

integer $index

Returns

string|boolean

pclzipLocateName()

pclzipLocateName(string  $filename) : integer

Returns the index of the entry in the archive (emulate \ZipArchive)

Parameters

string $filename

Filename for the file in zip archive

Returns

integer

addFile()

addFile(string  $filename, string  $localname = null) : boolean

Parameters

string $filename
string $localname

Returns

boolean

addFromString()

addFromString(string  $localname, string  $contents) : boolean

Parameters

string $localname
string $contents

Returns

boolean

getNameIndex()

getNameIndex(integer  $index) : string

Parameters

integer $index

Returns

string

locateName()

locateName(string  $name) : integer

Parameters

string $name

Returns

integer