Simplify department name retrieval logic in Redis class

Replaced JSON decoding with direct object casting for department data, reducing unnecessary parsing overhead. This change ensures a more efficient and straightforward handling of the `get_department_name` function.
This commit is contained in:
Jepp9350
2025-01-30 16:59:33 +01:00
parent 2663c09455
commit 13fb3a10ae
+2 -2
View File
@@ -105,12 +105,12 @@ class redis implements redis_i
public function get_department_name(int $department_id): string|null
{
// Get the department name
$tmp_department = $this->get('department_' . $department_id);
$tmp_department = (object)$this->get('department_' . $department_id) ?? null;
if ($tmp_department === 'IS_EMPTY_OR_NULL' || $tmp_department === null) {
return null;
}
// Return the department name
return json_decode($tmp_department, true)->name;
return $tmp_department->name;
}
/**