You are here

public function MergeYaml::getMergedYmlContent in Database Sanitize 7

Returns the content of the merged yaml files.

Parameters

array $filePaths: An array containing the file paths.

Return value

string The yaml content.

1 call to MergeYaml::getMergedYmlContent()
MergeYaml::createMergeFiles in vendor/edisonlabs/merge-yaml/src/MergeYaml.php
Create the merge files.

File

vendor/edisonlabs/merge-yaml/src/MergeYaml.php, line 78

Class

MergeYaml
Main class for merge-yaml.

Namespace

EdisonLabs\MergeYaml

Code

public function getMergedYmlContent(array $filePaths) {
  $mergedValue = array();
  foreach ($filePaths as $filePath) {
    try {
      $fileContent = file_get_contents($filePath);
      $parsedFile = Yaml::parse($fileContent);
    } catch (ParseException $exception) {
      throw new \RuntimeException(sprintf("Unable to parse the file %s as YAML: %s", $filePath, $exception
        ->getMessage()));
    }
    if (!is_array($parsedFile)) {
      $parsedFile = array();
    }
    $mergedValue = array_merge_recursive($mergedValue, $parsedFile);
  }
  return Yaml::dump($mergedValue, PHP_INT_MAX, 2);
}