original_string: public static function replaceEnvVariables($yaml): string
      {
          $matches = null;
          preg_match_all('/%\w+%/', $yaml, $matches);
          $originalValues = $matches[0];
          $replaceValues = [];
          foreach ($originalValues as $match) {
              $envVariable = substr($match, 1, -1);
              $envValue = getenv($envVariable);
              if (!$envValue) {
                  $envVariable = strtoupper($envVariable);
                  $envVariable = 'SCHEMATIC_'.$envVariable;
                  $envValue = getenv($envVariable);
                  if (!$envValue) {
                      throw new Exception("Schematic environment variable not set: {$envVariable}");
                  }
              }
              $replaceValues[] = $envValue;
          }
  
          return str_replace($originalValues, $replaceValues, $yaml);
      }
code: public static function replaceEnvVariables($yaml): string
      {
          $matches = null;
          preg_match_all('/%\w+%/', $yaml, $matches);
          $originalValues = $matches[0];
          $replaceValues = [];
          foreach ($originalValues as $match) {
              $envVariable = substr($match, 1, -1);
              $envValue = getenv($envVariable);
              if (!$envValue) {
                  $envVariable = strtoupper($envVariable);
                  $envVariable = 'SCHEMATIC_'.$envVariable;
                  $envValue = getenv($envVariable);
                  if (!$envValue) {
                      throw new Exception("Schematic environment variable not set: {$envVariable}");
                  }
              }
              $replaceValues[] = $envValue;
          }
  
          return str_replace($originalValues, $replaceValues, $yaml);
      }
code_tokens: public static function replaceEnvVariables ( $ yaml ) : string { $ matches = null ; preg_match_all ( '/%\w+%/' , $ yaml , $ matches ) ; $ originalValues = $ matches [ 0 ] ; $ replaceValues = [ ] ; foreach ( $ originalValues as $ match ) { $ envVariable = substr ( $ match , 1 , - 1 ) ; $ envValue = getenv ( $ envVariable ) ; if ( ! $ envValue ) { $ envVariable = strtoupper ( $ envVariable ) ; $ envVariable = 'SCHEMATIC_' . $ envVariable ; $ envValue = getenv ( $ envVariable ) ; if ( ! $ envValue ) { throw new Exception ( "Schematic environment variable not set: {$envVariable}" ) ; } } $ replaceValues [ ] = $ envValue ; } return str_replace ( $ originalValues , $ replaceValues , $ yaml ) ; }
docstring: Replace placeholders with enviroment variables.
  
  Placeholders start with % and end with %. This will be replaced by the
  environment variable with the name SCHEMATIC_{PLACEHOLDER}. If the
  environment variable is not set an exception will be thrown.
  
  @param string $yaml
  
  @return string
  
  @throws Exception
docstring_tokens: Replace placeholders with enviroment variables .