Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Sep 29, 2024
1 parent 0880b6a commit 650bf45
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/ZugferdDocumentPdfReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace horstoeko\zugferd;

use Exception;
use Smalot\PdfParser\Parser as PdfParser;
use horstoeko\zugferd\exception\ZugferdFileNotFoundException;
use horstoeko\zugferd\exception\ZugferdFileNotReadableException;
Expand All @@ -28,14 +29,21 @@ class ZugferdDocumentPdfReader
/**
* List of filenames which are possible in PDF
*/
public const ATTACHMENT_FILENAMES = ['ZUGFeRD-invoice.xml'/*1.0*/, 'zugferd-invoice.xml'/*2.0*/, 'factur-x.xml'/*2.1*/, 'xrechnung.xml'];
public const ATTACHMENT_FILENAMES = [
'ZUGFeRD-invoice.xml'/*1.0*/,
'zugferd-invoice.xml'/*2.0*/,
'factur-x.xml'/*2.1*/,
'xrechnung.xml'
];

/**
* Load a PDF file (ZUGFeRD/Factur-X)
*
* @param string $pdfFilename
* Contains a full-qualified filename which must exist and must be readable
* @param string $pdfFilename Contains a full-qualified filename which must exist and must be readable
* @return ZugferdDocumentReader|null
* @throws ZugferdFileNotFoundException
* @throws ZugferdFileNotReadableException
* @throws Exception
*/
public static function readAndGuessFromFile(string $pdfFilename): ?ZugferdDocumentReader
{
Expand All @@ -56,9 +64,9 @@ public static function readAndGuessFromFile(string $pdfFilename): ?ZugferdDocume
* Tries to load an attachment content from PDF and return a ZugferdDocumentReader
* If any erros occured or no attachments were found null is returned
*
* @param string $pdfContent
* String Containing the binary pdf data
* @param string $pdfContent String Containing the binary pdf data
* @return ZugferdDocumentReader|null
* @throws Exception
*/
public static function readAndGuessFromContent(string $pdfContent): ?ZugferdDocumentReader
{
Expand All @@ -81,8 +89,11 @@ public static function readAndGuessFromContent(string $pdfContent): ?ZugferdDocu
* @param string $pdfFilename
* Contains a full-qualified filename which must exist and must be readable
* @return string|null
* @throws ZugferdFileNotFoundException
* @throws ZugferdFileNotReadableException
* @throws Exception
*/
public static function getXmlFromFile(string $pdfFilename) : ?string
public static function getXmlFromFile(string $pdfFilename): ?string
{
if (!file_exists($pdfFilename)) {
throw new ZugferdFileNotFoundException($pdfFilename);
Expand All @@ -100,11 +111,11 @@ public static function getXmlFromFile(string $pdfFilename) : ?string
/**
* Returns a XML content from a PDF binary stream (string)
*
* @param string $pdfContent
* String Containing the binary pdf data
* @param string $pdfContent String Containing the binary pdf data
* @return string|null
* @throws Exception
*/
public static function getXmlFromContent(string $pdfContent) : ?string
public static function getXmlFromContent(string $pdfContent): ?string
{
return static::internalExtractXMLFromPdfContent($pdfContent);
}
Expand All @@ -114,7 +125,8 @@ public static function getXmlFromContent(string $pdfContent) : ?string
* See the allowed filenames which are supported
*
* @param string $pdfContent
* @return string|null
* @return null|string
* @throws Exception
*/
private static function internalExtractXMLFromPdfContent(string $pdfContent): ?string
{
Expand Down

0 comments on commit 650bf45

Please sign in to comment.