| @@ 79-91 (lines=13) @@ | ||
| 76 | * @throws \RuntimeException |
|
| 77 | * @return \Phinx\Config\Config |
|
| 78 | */ |
|
| 79 | public static function fromYaml($configFilePath) |
|
| 80 | { |
|
| 81 | $configFile = file_get_contents($configFilePath); |
|
| 82 | $configArray = Yaml::parse($configFile); |
|
| 83 | ||
| 84 | if (!is_array($configArray)) { |
|
| 85 | throw new \RuntimeException(sprintf( |
|
| 86 | 'File \'%s\' must be valid YAML', |
|
| 87 | $configFilePath |
|
| 88 | )); |
|
| 89 | } |
|
| 90 | ||
| 91 | return new static($configArray, $configFilePath); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| @@ 101-111 (lines=11) @@ | ||
| 98 | * @throws \RuntimeException |
|
| 99 | * @return \Phinx\Config\Config |
|
| 100 | */ |
|
| 101 | public static function fromJson($configFilePath) |
|
| 102 | { |
|
| 103 | $configArray = json_decode(file_get_contents($configFilePath), true); |
|
| 104 | if (!is_array($configArray)) { |
|
| 105 | throw new \RuntimeException(sprintf( |
|
| 106 | 'File \'%s\' must be valid JSON', |
|
| 107 | $configFilePath |
|
| 108 | )); |
|
| 109 | } |
|
| 110 | ||
| 111 | return new static($configArray, $configFilePath); |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| @@ 121-138 (lines=18) @@ | ||
| 118 | * @throws \RuntimeException |
|
| 119 | * @return \Phinx\Config\Config |
|
| 120 | */ |
|
| 121 | public static function fromPhp($configFilePath) |
|
| 122 | { |
|
| 123 | ob_start(); |
|
| 124 | /** @noinspection PhpIncludeInspection */ |
|
| 125 | $configArray = include($configFilePath); |
|
| 126 | ||
| 127 | // Hide console output |
|
| 128 | ob_end_clean(); |
|
| 129 | ||
| 130 | if (!is_array($configArray)) { |
|
| 131 | throw new \RuntimeException(sprintf( |
|
| 132 | 'PHP file \'%s\' must return an array', |
|
| 133 | $configFilePath |
|
| 134 | )); |
|
| 135 | } |
|
| 136 | ||
| 137 | return new static($configArray, $configFilePath); |
|
| 138 | } |
|
| 139 | ||
| 140 | /** |
|
| 141 | * {@inheritdoc} |
|