/** * @param $username * @return User|null */ public function getUserByUsername($username) { try { $query = new \CultureFeed_SearchUsersQuery(); $query->nick = $username; $results = $this->cultureFeed->searchUsers($query); $users = $results->objects; if (empty($users)) { return null; } $user = reset($users); return $this->getUser($user->id); } catch (\CultureFeed_ParseException $e) { return null; } }