$tagString) { $tags[$index] = strtolower($tagString); } return $tags; } public function getNamesFromTags(array $tags) { $names = array(); foreach ($tags as $tagString) { $names[] = trim($tagString, '@'); } return $names; } public function getIdsFromTags(array $tags) { $userModel = new UserModel(); $userIds = array(); $names = $this->getNamesFromTags($tags); foreach ($names as $username) { $userIds[] = $userModel->getIdFromUsername($username); } return $userIds; } public function getUserdataFromTags(array $tags) { $userModel = new UserModel(); $usersData = array(); foreach ($tags as $tagString) { $usersData[$userModel->getIdFromUsername(trim($tagString, '@'))] = $tagString; } return $usersData; } public function getUserTagDataFromString($text) { $allTags = $this->getUserTags($text); $userData = $this->getUserdataFromTags($allTags); return $userData; } public function replaceNotificationsWithLinks($text) { $modifiedText = $text; $userData = $this->getUserTagDataFromString($modifiedText); foreach($userData as $userId => $userTag) { $modifiedText = str_ireplace($userTag, "".$userTag."", $modifiedText); } return $modifiedText; } }