LSldap :: getAttr(): be sure to return on array when $multiple is true

This commit is contained in:
Benjamin Renard 2023-03-20 15:32:25 +01:00
parent f3e7557421
commit 58dbdcb7fe
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -333,12 +333,13 @@ class LSldap extends LSlog_staticLoggerClass {
* @param string $name Name of a attribute * @param string $name Name of a attribute
* @param boolean $multiple true if we must return array * @param boolean $multiple true if we must return array
* *
* @return mixed Found value (or array of values) or null * @return ($multiple is True ? array<int,string> : string|null) Found value (or array of values) or null
*/ */
public static function getAttr($attrs, $name, $multiple=false) { public static function getAttr($attrs, $name, $multiple=false) {
$name = strtolower($name); $name = strtolower($name);
foreach ($attrs as $k => $v) { foreach ($attrs as $k => $v) {
if (strtolower($k) === $name) { if (strtolower($k) === $name) {
$v = ensureIsArray($v);
return $multiple ? $v : $v[0]; return $multiple ? $v : $v[0];
} }
} }