From 87d6391ba4f65ed07fdb778abdac52b9d0ff451b Mon Sep 17 00:00:00 2001 From: Christian Schorn Date: Wed, 31 Oct 2012 18:03:42 +0100 Subject: [PATCH] Add `fromFile` factory method to `GitList\Config` --- boot.php | 2 +- src/GitList/Config.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/boot.php b/boot.php index 3a5b62b..d5aa475 100644 --- a/boot.php +++ b/boot.php @@ -1,7 +1,7 @@ set('git', 'repositories', rtrim($config->get('git', 'repositories'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR); // Startup and configure Silex application diff --git a/src/GitList/Config.php b/src/GitList/Config.php index a7f09e3..33d5b39 100644 --- a/src/GitList/Config.php +++ b/src/GitList/Config.php @@ -6,13 +6,17 @@ class Config { protected $data; - public function __construct($file) - { + public static function fromFile($file) { if (!file_exists($file)) { die(sprintf('Please, create the %1$s file.', $file)); } + $data = parse_ini_file($file, true); + return new static($data); + } - $this->data = parse_ini_file($file, true); + public function __construct($data) + { + $this->data = $data; $this->validateOptions(); }