@@ 28-53 (lines=26) @@ | ||
25 | * |
|
26 | * @since 0.2.0 |
|
27 | */ |
|
28 | class EnvLoader extends AbstractLoader |
|
29 | { |
|
30 | /** |
|
31 | * {@inheritdoc} |
|
32 | */ |
|
33 | public static $supported = array('env'); |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | * |
|
38 | * @throws \RuntimeException If `m1/env` library is not installed or the file can not be parsed |
|
39 | */ |
|
40 | public function load() |
|
41 | { |
|
42 | try { |
|
43 | $this->content = Parser::parse(file_get_contents($this->entity)); |
|
44 | } catch (\Exception $e) { |
|
45 | throw new \RuntimeException(sprintf( |
|
46 | "%s threw an exception: %s", |
|
47 | $this->entity, |
|
48 | $e |
|
49 | )); |
|
50 | } |
|
51 | return $this; |
|
52 | } |
|
53 | } |
|
54 |
@@ 28-51 (lines=24) @@ | ||
25 | * |
|
26 | * @since 0.1.0 |
|
27 | */ |
|
28 | class TomlLoader extends AbstractLoader |
|
29 | { |
|
30 | /** |
|
31 | * {@inheritdoc} |
|
32 | */ |
|
33 | public static $supported = array('toml', 'tml'); |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | * |
|
38 | * @throws \RuntimeException If the `yosymfonytoml` library is not installed or the toml file is not valid |
|
39 | */ |
|
40 | public function load() |
|
41 | { |
|
42 | try { |
|
43 | $this->content = Toml::parse($this->entity); |
|
44 | } catch (\Exception $e) { |
|
45 | throw new \RuntimeException( |
|
46 | sprintf("'%s' failed to load with the error '%s'", $this->entity, $e) |
|
47 | ); |
|
48 | } |
|
49 | return $this; |
|
50 | } |
|
51 | } |
|
52 |
@@ 28-54 (lines=27) @@ | ||
25 | * |
|
26 | * @since 0.1.0 |
|
27 | */ |
|
28 | class YamlLoader extends AbstractLoader |
|
29 | { |
|
30 | /** |
|
31 | * {@inheritdoc} |
|
32 | */ |
|
33 | public static $supported = array('yaml', 'yml'); |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | * |
|
38 | * @throws \RuntimeException If `symfony/yaml` library is not installed or the file can not be parsed |
|
39 | */ |
|
40 | public function load() |
|
41 | { |
|
42 | try { |
|
43 | $this->content = Yaml::parse(file_get_contents($this->entity)); |
|
44 | } catch (\Exception $e) { |
|
45 | throw new \RuntimeException(sprintf( |
|
46 | "%s threw an exception: %s", |
|
47 | $this->entity, |
|
48 | $e |
|
49 | )); |
|
50 | } |
|
51 | ||
52 | return $this; |
|
53 | } |
|
54 | } |
|
55 |