original_string: public function count() {
          global $DB;
          if ($this->totalcommentcount === null) {
              list($where, $component) = $this->get_component_select_sql();
              $where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid';
              $params = array(
                  'itemid' => $this->itemid,
                  'commentarea' => $this->commentarea,
                  'contextid' => $this->context->id,
              );
              if ($component) {
                  $params['component'] = $component;
              }
  
              $this->totalcommentcount = $DB->count_records_select('comments', $where, $params);
          }
          return $this->totalcommentcount;
      }
code: public function count() {
          global $DB;
          if ($this->totalcommentcount === null) {
              list($where, $component) = $this->get_component_select_sql();
              $where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid';
              $params = array(
                  'itemid' => $this->itemid,
                  'commentarea' => $this->commentarea,
                  'contextid' => $this->context->id,
              );
              if ($component) {
                  $params['component'] = $component;
              }
  
              $this->totalcommentcount = $DB->count_records_select('comments', $where, $params);
          }
          return $this->totalcommentcount;
      }
code_tokens: public function count ( ) { global $ DB ; if ( $ this -> totalcommentcount === null ) { list ( $ where , $ component ) = $ this -> get_component_select_sql ( ) ; $ where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid' ; $ params = array ( 'itemid' => $ this -> itemid , 'commentarea' => $ this -> commentarea , 'contextid' => $ this -> context -> id , ) ; if ( $ component ) { $ params [ 'component' ] = $ component ; } $ this -> totalcommentcount = $ DB -> count_records_select ( 'comments' , $ where , $ params ) ; } return $ this -> totalcommentcount ; }
docstring: Returns the number of comments associated with the details of this object
  
  @global moodle_database $DB
  @return int
docstring_tokens: Returns the number of comments associated with the details of this object