original_string: public static function build($params) {
          global $CFG;
  
          require_once($CFG->libdir . '/badgeslib.php');
  
          $types = badges_list_criteria(false);
  
          if (!isset($params['criteriatype']) || !isset($types[$params['criteriatype']])) {
              print_error('error:invalidcriteriatype', 'badges');
          }
  
          $class = 'award_criteria_' . $types[$params['criteriatype']];
          require_once($CFG->dirroot . '/badges/criteria/' . $class . '.php');
  
          return new $class($params);
      }
code: public static function build($params) {
          global $CFG;
  
          require_once($CFG->libdir . '/badgeslib.php');
  
          $types = badges_list_criteria(false);
  
          if (!isset($params['criteriatype']) || !isset($types[$params['criteriatype']])) {
              print_error('error:invalidcriteriatype', 'badges');
          }
  
          $class = 'award_criteria_' . $types[$params['criteriatype']];
          require_once($CFG->dirroot . '/badges/criteria/' . $class . '.php');
  
          return new $class($params);
      }
code_tokens: public static function build ( $ params ) { global $ CFG ; require_once ( $ CFG -> libdir . '/badgeslib.php' ) ; $ types = badges_list_criteria ( false ) ; if ( ! isset ( $ params [ 'criteriatype' ] ) || ! isset ( $ types [ $ params [ 'criteriatype' ] ] ) ) { print_error ( 'error:invalidcriteriatype' , 'badges' ) ; } $ class = 'award_criteria_' . $ types [ $ params [ 'criteriatype' ] ] ; require_once ( $ CFG -> dirroot . '/badges/criteria/' . $ class . '.php' ) ; return new $ class ( $ params ) ; }
docstring: Factory method for creating criteria class object
  
  @param array $params associative arrays varname => value
  @return award_criteria
docstring_tokens: Factory method for creating criteria class object