original_string: public static function factory($params) {
          global $CFG, $COMPLETION_CRITERIA_TYPES;
  
          if (!isset($params['criteriatype']) || !isset($COMPLETION_CRITERIA_TYPES[$params['criteriatype']])) {
              print_error('invalidcriteriatype', 'completion');
          }
  
          $class = 'completion_criteria_'.$COMPLETION_CRITERIA_TYPES[$params['criteriatype']];
          require_once($CFG->dirroot.'/completion/criteria/'.$class.'.php');
  
          return new $class($params, false);
      }
code: public static function factory($params) {
          global $CFG, $COMPLETION_CRITERIA_TYPES;
  
          if (!isset($params['criteriatype']) || !isset($COMPLETION_CRITERIA_TYPES[$params['criteriatype']])) {
              print_error('invalidcriteriatype', 'completion');
          }
  
          $class = 'completion_criteria_'.$COMPLETION_CRITERIA_TYPES[$params['criteriatype']];
          require_once($CFG->dirroot.'/completion/criteria/'.$class.'.php');
  
          return new $class($params, false);
      }
code_tokens: public static function factory ( $ params ) { global $ CFG , $ COMPLETION_CRITERIA_TYPES ; if ( ! isset ( $ params [ 'criteriatype' ] ) || ! isset ( $ COMPLETION_CRITERIA_TYPES [ $ params [ 'criteriatype' ] ] ) ) { print_error ( 'invalidcriteriatype' , 'completion' ) ; } $ class = 'completion_criteria_' . $ COMPLETION_CRITERIA_TYPES [ $ params [ 'criteriatype' ] ] ; require_once ( $ CFG -> dirroot . '/completion/criteria/' . $ class . '.php' ) ; return new $ class ( $ params , false ) ; }
docstring: Factory method for creating correct class object
  
  @param array $params associative arrays varname=>value
  @return completion_criteria
docstring_tokens: Factory method for creating correct class object