dolibarr.bankimport/vendor/nemiah/php-fints/lib/Fhp/Protocol/MessageBuilder.php
data 94efa59df3 v1.7: Multi-invoice payments and payment unlinking
- Add multi-invoice payment support (link one bank transaction to multiple invoices)
- Add payment unlinking feature to correct wrong matches
- Show linked payments, invoices and bank entries in transaction detail view
- Allow linking already paid invoices to bank transactions
- Update README with new features
- Add CHANGELOG.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-20 09:00:05 +01:00

50 lines
1.3 KiB
PHP
Executable file

<?php
namespace Fhp\Protocol;
use Fhp\Segment\BaseSegment;
/**
* Collects segments and assigns them segment numbers in order to form a {@link Message}.
*/
class MessageBuilder
{
/**
* This is where the builder collects the (unencrypted/unwrapped) segments as they are being added.
* @var BaseSegment[]
*/
public $segments = [];
/** @return MessageBuilder A new instance. */
public static function create(): MessageBuilder
{
return new MessageBuilder();
}
/**
* @param BaseSegment|BaseSegment[] $segments The segment(s) to be added.
* @return $this The same instance for chaining.
*/
public function add($segments)
{
if (is_array($segments)) {
foreach ($segments as $segment) {
$this->addInternal($segment);
}
} else {
$this->addInternal($segments);
}
return $this;
}
private function addInternal(BaseSegment $segment)
{
if ($segment->segmentkopf === null) {
throw new \InvalidArgumentException(
'Segment lacks Segmentkopf, maybe you called ctor instead of createEmpty()');
}
$this->segments[] = $segment;
}
// Note: There is no single build() function, use Message::createWrappedMessage() instead.
}