original_string: public function count_favourites_by_type(string $component, string $itemtype, \context $context = null) {
          $criteria = [
              'userid' => $this->userid,
              'component' => $component,
              'itemtype' => $itemtype
          ];
  
          if ($context) {
              $criteria['contextid'] = $context->id;
          }
  
          return $this->repo->count_by($criteria);
      }
code: public function count_favourites_by_type(string $component, string $itemtype, \context $context = null) {
          $criteria = [
              'userid' => $this->userid,
              'component' => $component,
              'itemtype' => $itemtype
          ];
  
          if ($context) {
              $criteria['contextid'] = $context->id;
          }
  
          return $this->repo->count_by($criteria);
      }
code_tokens: public function count_favourites_by_type ( string $ component , string $ itemtype , \ context $ context = null ) { $ criteria = [ 'userid' => $ this -> userid , 'component' => $ component , 'itemtype' => $ itemtype ] ; if ( $ context ) { $ criteria [ 'contextid' ] = $ context -> id ; } return $ this -> repo -> count_by ( $ criteria ) ; }
docstring: Count the favourite by item type.
  
  @param string $component the frankenstyle component name.
  @param string $itemtype the type of the favourited item.
  @param \context|null $context the context of the item which was favourited.
  @return int
docstring_tokens: Count the favourite by item type .