original_string: public function findNextSubcategory($subcategory)
      {
          $qb = $this->getQueryBuilder()
              ->select('c')
              ->where('c.id > :id')
              ->andWhere('c.parentCategory = :parentCategory')
              ->orderBy('c.id', 'asc')
              ->setMaxResults(1)
              ->setParameter('id', $subcategory->getId())
              ->setParameter('parentCategory', $subcategory->getParentCategory());
  
          // get the first subcategory when there is no next
          if (0 == count($qb->getQuery()->getResult())) {
              $qb->where('c.id < :id')
                  ->andWhere('c.parentCategory = :parentCategory')
                  ->setParameter('id', $subcategory->getId())
                  ->setParameter('parentCategory', $subcategory->getParentCategory());
  
              if (0 == count($qb->getQuery()->getResult())) {
                  return null;
              }
          }
  
          return $qb->getQuery()
              ->getSingleResult();
      }
code: public function findNextSubcategory($subcategory)
      {
          $qb = $this->getQueryBuilder()
              ->select('c')
              ->where('c.id > :id')
              ->andWhere('c.parentCategory = :parentCategory')
              ->orderBy('c.id', 'asc')
              ->setMaxResults(1)
              ->setParameter('id', $subcategory->getId())
              ->setParameter('parentCategory', $subcategory->getParentCategory());
  
          // get the first subcategory when there is no next
          if (0 == count($qb->getQuery()->getResult())) {
              $qb->where('c.id < :id')
                  ->andWhere('c.parentCategory = :parentCategory')
                  ->setParameter('id', $subcategory->getId())
                  ->setParameter('parentCategory', $subcategory->getParentCategory());
  
              if (0 == count($qb->getQuery()->getResult())) {
                  return null;
              }
          }
  
          return $qb->getQuery()
              ->getSingleResult();
      }
code_tokens: public function findNextSubcategory ( $ subcategory ) { $ qb = $ this -> getQueryBuilder ( ) -> select ( 'c' ) -> where ( 'c.id > :id' ) -> andWhere ( 'c.parentCategory = :parentCategory' ) -> orderBy ( 'c.id' , 'asc' ) -> setMaxResults ( 1 ) -> setParameter ( 'id' , $ subcategory -> getId ( ) ) -> setParameter ( 'parentCategory' , $ subcategory -> getParentCategory ( ) ) ; // get the first subcategory when there is no next if ( 0 == count ( $ qb -> getQuery ( ) -> getResult ( ) ) ) { $ qb -> where ( 'c.id < :id' ) -> andWhere ( 'c.parentCategory = :parentCategory' ) -> setParameter ( 'id' , $ subcategory -> getId ( ) ) -> setParameter ( 'parentCategory' , $ subcategory -> getParentCategory ( ) ) ; if ( 0 == count ( $ qb -> getQuery ( ) -> getResult ( ) ) ) { return null ; } } return $ qb -> getQuery ( ) -> getSingleResult ( ) ; }
docstring: Find the next subcategory, or the first one if none is found
  
  @param Category $subcategory
  
  @return Category|null
docstring_tokens: Find the next subcategory or the first one if none is found