Office_Parser implements Parser_Interface

Parser for Office Open XML files (docx, xlsx, pptx).

Tags
author

Barn2 Plugins [email protected]

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Parser_Interface
Interface for document parsers.

Table of Contents

extract()  : string
Extract plaintext content from the given file.
assert_requirements()  : void
Ensure required PHP extensions are available.
extract_docx_text()  : string
Extract text from DOCX.
extract_pptx_text()  : string
Extract text from PPTX.
extract_xlsx_text()  : string
Extract text from XLSX.
extract_xml_text()  : string
Extract plaintext from XML text nodes.
get_entries_by_pattern()  : array<int, string>
Return archive file entries matching a regex pattern.
load_xml()  : bool
Load XML safely while capturing parser warnings.
normalize_text()  : string
Normalize parser output.

Methods

extract()

Extract plaintext content from the given file.

public extract(string $file_path) : string
Parameters
$file_path : string

Absolute file path.

Tags
Return values
string

assert_requirements()

Ensure required PHP extensions are available.

private assert_requirements() : void
Tags
throws
Parse_Exception

When a required extension is unavailable.

Return values
void

extract_docx_text()

Extract text from DOCX.

private extract_docx_text(ZipArchive $zip) : string
Parameters
$zip : ZipArchive

The archive.

Tags
Return values
string

extract_pptx_text()

Extract text from PPTX.

private extract_pptx_text(ZipArchive $zip) : string
Parameters
$zip : ZipArchive

The archive.

Tags
Return values
string

extract_xlsx_text()

Extract text from XLSX.

private extract_xlsx_text(ZipArchive $zip) : string
Parameters
$zip : ZipArchive

The archive.

Tags
Return values
string

extract_xml_text()

Extract plaintext from XML text nodes.

private extract_xml_text(string $xml) : string
Parameters
$xml : string

XML content.

Tags
Return values
string

get_entries_by_pattern()

Return archive file entries matching a regex pattern.

private get_entries_by_pattern(ZipArchive $zip, string $pattern) : array<int, string>
Parameters
$zip : ZipArchive

Archive instance.

$pattern : string

Regex pattern.

Tags
Return values
array<int, string>

load_xml()

Load XML safely while capturing parser warnings.

private load_xml(DOMDocument $dom, string $xml) : bool
Parameters
$dom : DOMDocument

DOM document.

$xml : string

XML payload.

Tags
Return values
bool

normalize_text()

Normalize parser output.

private normalize_text(string $text) : string
Parameters
$text : string

Raw extracted text.

Tags
Return values
string

Search results