dolibarr.bankimport/vendor/nemiah/php-fints/lib/Fhp/Segment/AnonymousSegment.php
data 014a943f78 feat: HKEKA-Implementierung, PDF-Bugfixes, Sortierung, Umsatz-Umbenennung
- HKEKA v3/v4/v5 Segmente fuer phpFinTS implementiert (VR Bank unterstuetzt kein HKEKP)
- GetElectronicStatement Action mit Base64-Erkennung und Quittungscode
- PDF-Deduplizierung per MD5 (Bank sendet identische Saldenmitteilungen)
- Saldenmitteilungen ohne Auszugsnummer werden uebersprungen
- Datums-Validierung: 30.02. (Bank-Konvention) wird auf 28.02. korrigiert
- Numerische Sortierung fuer statement_number (CAST statt String-Sort)
- Jahr-Filter: statement_year=0 ausgeschlossen
- Menue/Button: "Kontoauszuege" -> "Umsaetze" (statements.php zeigt MT940, nicht PDFs)
- Redirect nach FinTS-Abruf auf aktuelles Jahr statt year=0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 07:10:59 +01:00

104 lines
3.5 KiB
PHP
Executable file

<?php
namespace Fhp\Segment;
use Fhp\Syntax\Delimiter;
use Fhp\Syntax\Parser;
/**
* A fallback for segments that were received from the server but are not implemented in this library.
*/
final class AnonymousSegment extends BaseSegment implements \Serializable
{
/**
* The type plus version of the segment, i.e. the class name of the class that would normally implement it.
* This is redundant with super::$segmentkopf, but it's useful to repeat here so that it shows up in a debugger.
*/
public string $type;
/**
* Contains the data elements of the segment. Some of them can be scalar values (represented as strings), and others
* can be nested data element groups of strings.
*
* NOTE: This field is intentionally private and does not have a getter. Reading this field anywhere besides for
* debugging purposes (e.g. in an interactive debugger or with print_r()) is wrong, please create a concrete
* subclass of BaseSegment instead.
*
* @var string[]|string[][]
*/
private array $elements;
/**
* @param string[]|string[][] $elements
*/
public function __construct(Segmentkopf $segmentkopf, array $elements)
{
$this->segmentkopf = $segmentkopf;
$this->type = $segmentkopf->segmentkennung . 'v' . $segmentkopf->segmentversion;
$this->elements = $elements;
}
public function getDescriptor(): SegmentDescriptor
{
throw new \RuntimeException('AnonymousSegments do not have a descriptor');
}
public function validate()
{
// Do nothing, anonymous segments are always valid.
}
/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*/
public function serialize(): string
{
return $this->__serialize()[0];
}
/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*
* @return void
*/
public function unserialize($serialized)
{
self::__unserialize([$serialized]);
}
public function __serialize(): array
{
$result = $this->segmentkopf->serialize() . Delimiter::ELEMENT .
implode(Delimiter::ELEMENT, array_map(function ($element) {
if ($element === null) {
return '';
}
if (is_string($element)) {
return $element;
}
return implode(Delimiter::GROUP, $element);
}, $this->elements))
. Delimiter::SEGMENT;
return [$result];
}
public function __unserialize(array $serialized): void
{
$parsed = Parser::parseAnonymousSegment($serialized[0]);
$this->type = $parsed->type;
$this->segmentkopf = $parsed->segmentkopf;
$this->elements = $parsed->elements;
}
/**
* Just to override the super factory.
* @noinspection PhpUnnecessaryStaticReferenceInspection
*/
public static function createEmpty(): static
{
// Note: createEmpty() normally runs the constructor and then fills the Segmentkopf, but that is not possible
// for AnonymousSegment. Callers should just call the constructor itself.
throw new \RuntimeException('AnonymousSegment::createEmpty() is not allowed');
}
}