19 lines
608 B
PHP
19 lines
608 B
PHP
<?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;
|
||
|
|
}
|