original_string: private function category($item) {
          global $DB;
  
          if (empty($item->categoryid)) {
  
              if ($item->itemtype == 'course') {
                  return $this->course->fullname;
              }
  
              $params = array('id' => $item->iteminstance);
              $elem = $DB->get_record('grade_categories', $params);
  
              return $elem->fullname;
          }
  
          if (!isset($this->categories[$item->categoryid])) {
              $category = $item->get_parent_category();
  
              $this->categories[$category->id] = $category;
          }
  
          return $this->categories[$item->categoryid]->get_name();
      }
code: private function category($item) {
          global $DB;
  
          if (empty($item->categoryid)) {
  
              if ($item->itemtype == 'course') {
                  return $this->course->fullname;
              }
  
              $params = array('id' => $item->iteminstance);
              $elem = $DB->get_record('grade_categories', $params);
  
              return $elem->fullname;
          }
  
          if (!isset($this->categories[$item->categoryid])) {
              $category = $item->get_parent_category();
  
              $this->categories[$category->id] = $category;
          }
  
          return $this->categories[$item->categoryid]->get_name();
      }
code_tokens: private function category ( $ item ) { global $ DB ; if ( empty ( $ item -> categoryid ) ) { if ( $ item -> itemtype == 'course' ) { return $ this -> course -> fullname ; } $ params = array ( 'id' => $ item -> iteminstance ) ; $ elem = $ DB -> get_record ( 'grade_categories' , $ params ) ; return $ elem -> fullname ; } if ( ! isset ( $ this -> categories [ $ item -> categoryid ] ) ) { $ category = $ item -> get_parent_category ( ) ; $ this -> categories [ $ category -> id ] = $ category ; } return $ this -> categories [ $ item -> categoryid ] -> get_name ( ) ; }
docstring: Helper to get the category for an item.
  
  @param grade_item $item
  @return grade_category
docstring_tokens: Helper to get the category for an item .