first version that reads birthday reminder files
[bdrem.git] / src / bdrem / Config.php
1 <?php
2 namespace bdrem;
3
4 class Config
5 {
6     public $source;
7     public $daysBefore;
8     public $daysAfter;
9
10     public function load()
11     {
12         $f = __DIR__ . '/../../data/bdrem.config.php';
13         if (file_exists($f)) {
14             return $this->loadFile($f);
15         }
16
17         throw new \Exception('No config file found');
18     }
19
20     protected function loadFile($filename)
21     {
22         include $filename;
23         $this->source = $source;
24         $this->daysBefore = $daysBefore;
25         $this->daysAfter = $daysAfter;
26     }
27
28     public function loadSource()
29     {
30         if ($this->source === null) {
31             throw new \Exception('No source defined');
32         }
33
34         $settings = $this->source;
35         $class = '\\bdrem\\Source_' . array_shift($settings);
36
37         return new $class($settings[0]);
38         //$rm = new \ReflectionMethod($class, '__construct');
39         //return $rm->invokeArgs(null, $settings);
40         //return call_user_func_array($class . '::__construct', $settings);
41     }
42 }
43 ?>