From 5b0ff0c8536c978b7bdab8278a2028ef209c40f2 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Mon, 4 Nov 2024 17:42:06 -0500 Subject: [PATCH] Handle null names more gracefully --- SilMock/Google/Service/Directory/UsersResource.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/SilMock/Google/Service/Directory/UsersResource.php b/SilMock/Google/Service/Directory/UsersResource.php index 1eac160..474d65d 100644 --- a/SilMock/Google/Service/Directory/UsersResource.php +++ b/SilMock/Google/Service/Directory/UsersResource.php @@ -356,12 +356,14 @@ public function listUsers($parameters = []) $userEntry = json_decode($userRecord['data'], true); if ($this->doesUserMatch($userEntry, $parameters['query'])) { /** @var \Google_Service_Directory_UserName $newName */ + $nameEntry = $userEntry['name'] ?? null; + $givenName = $nameEntry['givenName'] ?? null; + $familyName = $nameEntry['familyName'] ?? null; + $fullName = $nameEntry['fullName'] ?? trim($givenName . ' ' . $familyName); $newName = new \Google_Service_Directory_UserName([ - 'familyName' => $userEntry['name']['familyName'], - 'fullName' => - $userEntry['name']['fullName'] ?? - $userEntry['name']['givenName'] . ' ' . $userEntry['name']['familyName'], - 'givenName' => $userEntry['name']['givenName'], + 'familyName' => $familyName, + 'fullName' => $fullName, + 'givenName' => $givenName, ]); $userEntry['customerId'] = $userEntry['primaryEmail']; /** @var \Google_Service_Directory_User $newEntry */