Skip to content

Class ZugferdKositValidator

HorstOeko edited this page Dec 28, 2024 · 21 revisions

Summary

Class representing the validator against Schematron (Kosit) for documents.

This class requires a JAVA running setup

Example

Validation of a document read by ZugferdDocumentPdfReader

$kositValidator = new ZugferdKositValidator();

$document = ZugferdDocumentPdfReader::readAndGuessFromFile("/tmp/invoice.pdf");
$kositValidator->setDocument($document)->disableCleanup()->validate();

if ($kositValidator->hasValidationErrors()) {
    echo "Validation failed";
    foreach ($kositValidator->getValidationErrors() as $validationError) {
        echo " - " . $validationError . PHP_EOL;
    }
} else {
    echo "mValidation passed";
}

Validation of a document read by ZugferdDocumentReader

$kositValidator = new ZugferdKositValidator();

$document = ZugferdDocumentReader::readAndGuessFromFile("/tmp/factur-x.xml");
$kositValidator->setDocument($document)->disableCleanup()->validate();

if ($kositValidator->hasValidationErrors()) {
    echo "Validation failed";
    foreach ($kositValidator->getValidationErrors() as $validationError) {
        echo " - " . $validationError . PHP_EOL;
    }
} else {
    echo "mValidation passed";
}

Methods

fromString [static]

Summary

Create a KositValidator-Instance by a given content string

Signature

public static function fromString(string $document): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
document string

Returns

Returns a value of type \ZugferdKositValidator

fromZugferdDocument [static]

Summary

Create a KositValidator-Instance by a given ZugferdDocument (ZugferdDocumentReader, ZugferdDocumentBuilder)

Signature

public static function fromZugferdDocument(
  horstoeko\zugferd\ZugferdDocument $zugferdDocument,
): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
zugferdDocument horstoeko\zugferd\ZugferdDocument

Returns

Returns a value of type \ZugferdKositValidator

__construct

Summary

Constructor

Signature

public function __construct(mixed $document = null): void
{
}

Parameters

Name Type Allows Null Description
document mixed

setDocument

Summary

Set the ZugferdDocument instance to validate

Signature

public function setDocument(mixed $document): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
document mixed

Returns

Returns a value of type \ZugferdKositValidator

setBaseDirectory

Summary

Setup the base directory. In the base directory all files will be downloaded
and created

Signature

public function setBaseDirectory(string $newBaseDirectory): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
newBaseDirectory string

Returns

Returns a value of type \ZugferdKositValidator

setValidatorDownloadUrl

Summary

Setup the KOSIT validator application download url

Signature

public function setValidatorDownloadUrl(string $newValidatorDownloadUrl): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
newValidatorDownloadUrl string

Returns

Returns a value of type \ZugferdKositValidator

setValidatorScenarioDownloadUrl

Summary

Setup the KOSIT validator scenario download url

Signature

public function setValidatorScenarioDownloadUrl(string $newValidatorScenarioDownloadUrl): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
newValidatorScenarioDownloadUrl string

Returns

Returns a value of type \ZugferdKositValidator

setValidatorAppZipFilename

Summary

Set the filename of the ZIP file which contains the validation application

Signature

public function setValidatorAppZipFilename(string $newValidatorAppZipFilename): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
newValidatorAppZipFilename string

Returns

Returns a value of type \ZugferdKositValidator

setValidatorScenarioZipFilename

Summary

Set the filename of the ZIP file which contains the validation scenarios

Signature

public function setValidatorScenarioZipFilename(string $newValidatorScenarioZipFilename): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
newValidatorScenarioZipFilename string

Returns

Returns a value of type \ZugferdKositValidator

setValidatorAppJarFilename

Summary

Set the filename of the applications JAR

Signature

public function setValidatorAppJarFilename(string $newValidatorAppJarFilename): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
newValidatorAppJarFilename string

Returns

Returns a value of type \ZugferdKositValidator

setValidatorAppScenarioFilename

Summary

Set the filename of the application scenario file

Signature

public function setValidatorAppScenarioFilename(string $newValidatorAppScenarioFilename): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
newValidatorAppScenarioFilename string

Returns

Returns a value of type \ZugferdKositValidator

disableCleanup

Summary

Disable cleanup base directory

Signature

public function disableCleanup(): \ZugferdKositValidator
{
}

Returns

Returns a value of type \ZugferdKositValidator

enableCleanup

Summary

Enable cleanup base directory

Signature

public function enableCleanup(): \ZugferdKositValidator
{
}

Returns

Returns a value of type \ZugferdKositValidator

disableRemoteMode

Summary

Disable the usage of a remote host validation

Signature

public function disableRemoteMode(): \ZugferdKositValidator
{
}

Returns

Returns a value of type \ZugferdKositValidator

enableRemoteMode

Summary

Enable the usage of a remote host validation

Signature

public function enableRemoteMode(): \ZugferdKositValidator
{
}

Returns

Returns a value of type \ZugferdKositValidator

setRemoteModeHost

Summary

Set the hostname or the ip of the remote host where the validation application
is running in daemon mode

Signature

public function setRemoteModeHost(string $remoteModeHost): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
remoteModeHost string

Returns

Returns a value of type \ZugferdKositValidator

setRemoteModePort

Summary

Set the port of the remote host where the validation application
is running in daemon mode

Signature

public function setRemoteModePort(int $remoteModePort): \ZugferdKositValidator
{
}

Parameters

Name Type Allows Null Description
remoteModePort int

Returns

Returns a value of type \ZugferdKositValidator

getRemoteModeUrl

Summary

Returns the full remote mode URL

Signature

public function getRemoteModeUrl(): string
{
}

Returns

Returns a value of type string

validate

Summary

Perform validation

Signature

public function validate(): \ZugferdKositValidator
{
}

Returns

Returns a value of type \ZugferdKositValidator

getValidationErrors

Summary

Returns an array of all validation errors

Signature

public function getValidationErrors(): array
{
}

Returns

Returns a value of type array

hasNoValidationErrors

Summary

Returns true if no validation errors are present otherwise false

Signature

public function hasNoValidationErrors(): bool
{
}

Returns

Returns a value of type bool

hasValidationErrors

Summary

Returns true if validation errors are present otherwise false

Signature

public function hasValidationErrors(): bool
{
}

Returns

Returns a value of type bool

getValidationWarnings

Summary

Returns an array of all validation warnings

Signature

public function getValidationWarnings(): array
{
}

Returns

Returns a value of type array

hasNoValidationWarnings

Summary

Returns true if no validation warnings are present otherwise false

Signature

public function hasNoValidationWarnings(): bool
{
}

Returns

Returns a value of type bool

hasValidationWarnings

Summary

Returns true if validation warnings are present otherwise false

Signature

public function hasValidationWarnings(): bool
{
}

Returns

Returns a value of type bool

getValidationInformation

Summary

Returns an array of all validation information

Signature

public function getValidationInformation(): array
{
}

Returns

Returns a value of type array

hasNoValidationInformation

Summary

Returns true if no validation information are present otherwise false

Signature

public function hasNoValidationInformation(): bool
{
}

Returns

Returns a value of type bool

hasValidationInformation

Summary

Returns true if validation Information are present otherwise false

Signature

public function hasValidationInformation(): bool
{
}

Returns

Returns a value of type bool

getProcessErrors

Summary

Return an array of all internal errors (such as download error or system exceptions)

Signature

public function getProcessErrors(): array
{
}

Returns

Returns a value of type array

hasNoProcessErrors

Summary

Returns true if there are no system errors (e.g. exceptions before the validation app was called)

Signature

public function hasNoProcessErrors(): bool
{
}

Returns

Returns a value of type bool

hasProcessErrors

Summary

Returns true if there are any system errors (e.g. exceptions before the validation app was called)

Signature

public function hasProcessErrors(): bool
{
}

Returns

Returns a value of type bool

getProcessOutput

Summary

Returns an array of all messages from process system (calling external applications)

Signature

public function getProcessOutput(): array
{
}

Returns

Returns a value of type array

Clone this wiki locally