original_string: protected function getChoiceBySelection($selection)
      {
          preg_match('/^[^(]+\(([^\)]+)\)$/', $selection, $matches);
          if (count($matches) < 2) {
              return;
          }
          $username = $matches[1];
          foreach ($this->choices as $item) {
              if ($item->getUsername() === $username) {
                  return $item;
              }
          }
  
          return;
      }
code: protected function getChoiceBySelection($selection)
      {
          preg_match('/^[^(]+\(([^\)]+)\)$/', $selection, $matches);
          if (count($matches) < 2) {
              return;
          }
          $username = $matches[1];
          foreach ($this->choices as $item) {
              if ($item->getUsername() === $username) {
                  return $item;
              }
          }
  
          return;
      }
code_tokens: protected function getChoiceBySelection ( $ selection ) { preg_match ( '/^[^(]+\(([^\)]+)\)$/' , $ selection , $ matches ) ; if ( count ( $ matches ) < 2 ) { return ; } $ username = $ matches [ 1 ] ; foreach ( $ this -> choices as $ item ) { if ( $ item -> getUsername ( ) === $ username ) { return $ item ; } } return ; }
docstring: Find User by username
  
  @param string $username
  
  @return User
docstring_tokens: Find User by username