Files
JobcardSystem/app/Domain/Client/ClientHelpers.php
T

19 lines
608 B
PHP
Raw Normal View History

2026-09-01 18:54:47 +02:00
<?php
declare(strict_types=1);
/**
* Return whether a client name already occurs in a list, ignoring case and outer whitespace.
* Existing entries may be strings or rows containing a `name` field.
*/
function client_name_is_duplicate(string $name, array $existingClients): bool
{
$candidate = strtolower(trim($name));
foreach ($existingClients as $existing) {
$existingName = is_array($existing) ? ($existing['name'] ?? '') : $existing;
if (is_string($existingName) && strtolower(trim($existingName)) === $candidate) {
return true;
}
}
return false;
}