original_string: public function createNewUser($serviceName, AbstractUser $response)
      {
          $data         = $this->parseServiceResponse($response);
          $existingUser = $this->userRepo->getByEmail($data['email']);
          // duplicated user verification
          if ($existingUser === null) {
              $data['password'] = str_random(40);
              $user = $this->userRepo->create($data);
              // create relation for new user and social integration
              $this->addSocialRelation($user, $serviceName, $response);
              return $user;
          } else {
              session()->put('url.intended', route('register'));
              throw new SocialException(
                  trans('gzero-social::common.email_already_in_use_message', ['service_name' => title_case($serviceName)])
              );
          }
      }
code: public function createNewUser($serviceName, AbstractUser $response)
      {
          $data         = $this->parseServiceResponse($response);
          $existingUser = $this->userRepo->getByEmail($data['email']);
          // duplicated user verification
          if ($existingUser === null) {
              $data['password'] = str_random(40);
              $user = $this->userRepo->create($data);
              // create relation for new user and social integration
              $this->addSocialRelation($user, $serviceName, $response);
              return $user;
          } else {
              session()->put('url.intended', route('register'));
              throw new SocialException(
                  trans('gzero-social::common.email_already_in_use_message', ['service_name' => title_case($serviceName)])
              );
          }
      }
code_tokens: public function createNewUser ( $ serviceName , AbstractUser $ response ) { $ data = $ this -> parseServiceResponse ( $ response ) ; $ existingUser = $ this -> userRepo -> getByEmail ( $ data [ 'email' ] ) ; // duplicated user verification if ( $ existingUser === null ) { $ data [ 'password' ] = str_random ( 40 ) ; $ user = $ this -> userRepo -> create ( $ data ) ; // create relation for new user and social integration $ this -> addSocialRelation ( $ user , $ serviceName , $ response ) ; return $ user ; } else { session ( ) -> put ( 'url.intended' , route ( 'register' ) ) ; throw new SocialException ( trans ( 'gzero-social::common.email_already_in_use_message' , [ 'service_name' => title_case ( $ serviceName ) ] ) ) ; } }
docstring: Function creates new user based on social service response and create relation with social integration in database.
  
  @param $serviceName    string name of social service
  @param $response       AbstractUser response data
  
  @return User
  @throws SocialException
docstring_tokens: Function creates new user based on social service response and create relation with social integration in database .