original_string: public function getDocumentBySlug($slug)
      {
          $search = $this->repository->createSearch();
          $search->addQuery(new TermQuery('slug', $slug), 'must');
  
          $results = $this->repository->execute($search);
  
          if (count($results) === 0) {
              $this->logger && $this->logger->warning(
                  sprintf("Can not render snippet for '%s' because content was not found.", $slug)
              );
  
              return null;
          }
  
          return $results->current();
      }
code: public function getDocumentBySlug($slug)
      {
          $search = $this->repository->createSearch();
          $search->addQuery(new TermQuery('slug', $slug), 'must');
  
          $results = $this->repository->execute($search);
  
          if (count($results) === 0) {
              $this->logger && $this->logger->warning(
                  sprintf("Can not render snippet for '%s' because content was not found.", $slug)
              );
  
              return null;
          }
  
          return $results->current();
      }
code_tokens: public function getDocumentBySlug ( $ slug ) { $ search = $ this -> repository -> createSearch ( ) ; $ search -> addQuery ( new TermQuery ( 'slug' , $ slug ) , 'must' ) ; $ results = $ this -> repository -> execute ( $ search ) ; if ( count ( $ results ) === 0 ) { $ this -> logger && $ this -> logger -> warning ( sprintf ( "Can not render snippet for '%s' because content was not found." , $ slug ) ) ; return null ; } return $ results -> current ( ) ; }
docstring: Retrieves document by slug.
  
  @param string $slug
  
  @return DocumentInterface|null
docstring_tokens: Retrieves document by slug .