original_string: public static function parse_age_digital_consent_map($ageconsentmap) {
  
          $ageconsentmapparsed = array();
          $countries = get_string_manager()->get_list_of_countries(true);
          $isdefaultvaluepresent = false;
          $lines = preg_split('/\r|\n/', $ageconsentmap, -1, PREG_SPLIT_NO_EMPTY);
          foreach ($lines as $line) {
              $arr = explode(",", $line);
              // Handle if there is more or less than one comma separator.
              if (count($arr) != 2) {
                  throw new \moodle_exception('agedigitalconsentmapinvalidcomma', 'error', '', $line);
              }
              $country = trim($arr[0]);
              $age = trim($arr[1]);
              // Check if default.
              if ($country == "*") {
                  $isdefaultvaluepresent = true;
              }
              // Handle if the presented value for country is not valid.
              if ($country !== "*" && !array_key_exists($country, $countries)) {
                  throw new \moodle_exception('agedigitalconsentmapinvalidcountry', 'error', '', $country);
              }
              // Handle if the presented value for age is not valid.
              if (!is_numeric($age)) {
                  throw new \moodle_exception('agedigitalconsentmapinvalidage', 'error', '', $age);
              }
              $ageconsentmapparsed[$country] = $age;
          }
          // Handle if a default value does not exist.
          if (!$isdefaultvaluepresent) {
              throw new \moodle_exception('agedigitalconsentmapinvaliddefault');
          }
  
          return $ageconsentmapparsed;
      }
code: public static function parse_age_digital_consent_map($ageconsentmap) {
  
          $ageconsentmapparsed = array();
          $countries = get_string_manager()->get_list_of_countries(true);
          $isdefaultvaluepresent = false;
          $lines = preg_split('/\r|\n/', $ageconsentmap, -1, PREG_SPLIT_NO_EMPTY);
          foreach ($lines as $line) {
              $arr = explode(",", $line);
              // Handle if there is more or less than one comma separator.
              if (count($arr) != 2) {
                  throw new \moodle_exception('agedigitalconsentmapinvalidcomma', 'error', '', $line);
              }
              $country = trim($arr[0]);
              $age = trim($arr[1]);
              // Check if default.
              if ($country == "*") {
                  $isdefaultvaluepresent = true;
              }
              // Handle if the presented value for country is not valid.
              if ($country !== "*" && !array_key_exists($country, $countries)) {
                  throw new \moodle_exception('agedigitalconsentmapinvalidcountry', 'error', '', $country);
              }
              // Handle if the presented value for age is not valid.
              if (!is_numeric($age)) {
                  throw new \moodle_exception('agedigitalconsentmapinvalidage', 'error', '', $age);
              }
              $ageconsentmapparsed[$country] = $age;
          }
          // Handle if a default value does not exist.
          if (!$isdefaultvaluepresent) {
              throw new \moodle_exception('agedigitalconsentmapinvaliddefault');
          }
  
          return $ageconsentmapparsed;
      }
code_tokens: public static function parse_age_digital_consent_map ( $ ageconsentmap ) { $ ageconsentmapparsed = array ( ) ; $ countries = get_string_manager ( ) -> get_list_of_countries ( true ) ; $ isdefaultvaluepresent = false ; $ lines = preg_split ( '/\r|\n/' , $ ageconsentmap , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ lines as $ line ) { $ arr = explode ( "," , $ line ) ; // Handle if there is more or less than one comma separator. if ( count ( $ arr ) != 2 ) { throw new \ moodle_exception ( 'agedigitalconsentmapinvalidcomma' , 'error' , '' , $ line ) ; } $ country = trim ( $ arr [ 0 ] ) ; $ age = trim ( $ arr [ 1 ] ) ; // Check if default. if ( $ country == "*" ) { $ isdefaultvaluepresent = true ; } // Handle if the presented value for country is not valid. if ( $ country !== "*" && ! array_key_exists ( $ country , $ countries ) ) { throw new \ moodle_exception ( 'agedigitalconsentmapinvalidcountry' , 'error' , '' , $ country ) ; } // Handle if the presented value for age is not valid. if ( ! is_numeric ( $ age ) ) { throw new \ moodle_exception ( 'agedigitalconsentmapinvalidage' , 'error' , '' , $ age ) ; } $ ageconsentmapparsed [ $ country ] = $ age ; } // Handle if a default value does not exist. if ( ! $ isdefaultvaluepresent ) { throw new \ moodle_exception ( 'agedigitalconsentmapinvaliddefault' ) ; } return $ ageconsentmapparsed ; }
docstring: Parse the agedigitalconsentmap setting into an array.
  
  @param  string $ageconsentmap The value of the agedigitalconsentmap setting
  @return array $ageconsentmapparsed
docstring_tokens: Parse the agedigitalconsentmap setting into an array .