DocumentItemUtils

🔧 hasKeyRecursive

Check de façon recursiv si il y a une clé particulière dans un array
function hasKeyRecursive(array $array, string $keyToFind): bool { if (array_key_exists($keyToFind, $array)) { return true; } // Recursive foreach ($array as $value) { if (is_array($value)) { if ($this->hasKeyRecursive($value, $keyToFind)) { return true; } } // ... (truncated)

⚙️ Parameters

↩️ Returns

(bool) True if the key is found, orther false

🔧 validateInput

Outil de validation d'inputs
function validateInput( $value, $fieldName): void { if ($value === null) { throw new \InvalidArgumentException("{$fieldName} cannot be null."); }

⚙️ Parameters

⚠️ Throws


🔧 extractVatRate

Extract numeric VAT rate
function extractVatRate(?string $vatRateString): string { if($vatRateString === null) { return '0'; } // Remove percentage sign and any spaces $rate = str_replace(['%', ' '], '', $vatRateString); return str_replace(',', '.', $rate); }

⚙️ Parameters

↩️ Returns

(string) Numeric VAT rate as string ( "20")

🔧 lineItemToArray

Convert a lineItem_callback object to an array
function lineItemToArray(lineItem_callback $lineItem): array { return [ 'unit_price' => $lineItem->unit_price, 'vat_rate' => $lineItem->vat_rate, 'quantity' => $lineItem->quantity, 'discount_type' => $lineItem->discount_type, 'discount_value' => $lineItem->discount_value, 'total' => [ 'total_ht' => $lineItem->total->total_ht, 'tva_amount' => $lineItem->total->tva_amount, // ... (truncated)

⚙️ Parameters

↩️ Returns

(array) The line item as an array