XRechnungValidator
in package
Validates XRechnung XML against the bundled UBL XSD schema. Both an in-memory entry point (validateContent) and a file-path entry point (validate) are provided; the file-path variant is a thin convenience wrapper around the in-memory one.
Table of Contents
Methods
- __construct() : mixed
- getErrors() : array<int, string>
- setErrors() : void
- Replace the entire error set. Used by callers that want to reset state between validation runs without instantiating a new validator.
- validate() : bool
- Convenience wrapper: read a file from disk, then validateContent.
- validateContent() : bool
- In-memory validation. Loads the XML string into a DOMDocument and runs schemaValidate against the configured XSD. No filesystem I/O other than reading the XSD itself.
Methods
__construct()
public
__construct([string $xsdFile = '' ]) : mixed
Parameters
- $xsdFile : string = ''
-
Optional override for the XSD file path. Defaults to the bundled XRechnungSchema.xsd.
getErrors()
public
getErrors() : array<int, string>
Return values
array<int, string> —The errors collected by the most recent validate / validateContent call.
setErrors()
Replace the entire error set. Used by callers that want to reset state between validation runs without instantiating a new validator.
public
setErrors(array<int, string> $errors) : void
Parameters
- $errors : array<int, string>
-
An array of error messages.
validate()
Convenience wrapper: read a file from disk, then validateContent.
public
validate(string $xmlFile) : bool
Returns false if the file does not exist or cannot be read.
Parameters
- $xmlFile : string
Return values
boolvalidateContent()
In-memory validation. Loads the XML string into a DOMDocument and runs schemaValidate against the configured XSD. No filesystem I/O other than reading the XSD itself.
public
validateContent(string $xml) : bool
Parameters
- $xml : string