@@ -2,6 +2,6 @@ |
||
2 | 2 | namespace LunixREST\Configuration; |
3 | 3 | |
4 | 4 | interface Configuration { |
5 | - public function get($key); |
|
6 | - public function set($key); |
|
5 | + public function get($key); |
|
6 | + public function set($key); |
|
7 | 7 | } |
@@ -17,5 +17,5 @@ |
||
17 | 17 | $helloWorld = new \HelloWorld\Models\HelloWorld(); |
18 | 18 | |
19 | 19 | return $helloWorld; |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -20,6 +20,6 @@ |
||
20 | 20 | |
21 | 21 | |
22 | 22 | public function get(Request $request): ResponseData{ |
23 | - return $this->geoPhone->lookupNumber($request->getInstance()); |
|
24 | - } |
|
23 | + return $this->geoPhone->lookupNumber($request->getInstance()); |
|
24 | + } |
|
25 | 25 | } |
@@ -10,54 +10,54 @@ |
||
10 | 10 | * @package LunixREST\Configuration |
11 | 11 | */ |
12 | 12 | class INIConfiguration implements Configuration { |
13 | - /** |
|
14 | - * @var null |
|
15 | - */ |
|
16 | - protected $nameSpace; |
|
17 | - /** |
|
18 | - * @var |
|
19 | - */ |
|
20 | - protected $filename; |
|
21 | - |
|
22 | - /** |
|
23 | - * @param string $filename |
|
24 | - * @param string $nameSpace |
|
25 | - */ |
|
26 | - public function __construct($filename, $nameSpace = null){ |
|
27 | - $this->filename = $filename; |
|
28 | - $this->nameSpace = $nameSpace; |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
13 | + /** |
|
14 | + * @var null |
|
15 | + */ |
|
16 | + protected $nameSpace; |
|
17 | + /** |
|
18 | + * @var |
|
19 | + */ |
|
20 | + protected $filename; |
|
21 | + |
|
22 | + /** |
|
23 | + * @param string $filename |
|
24 | + * @param string $nameSpace |
|
25 | + */ |
|
26 | + public function __construct($filename, $nameSpace = null){ |
|
27 | + $this->filename = $filename; |
|
28 | + $this->nameSpace = $nameSpace; |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | 32 | * //TODO: Move throws/loading to constructor to keep with get contract |
33 | - * @param $key |
|
34 | - * @return mixed |
|
35 | - * @throws INIKeyNotFoundException |
|
36 | - * @throws INIParseException |
|
37 | - */ |
|
38 | - public function get($key){ |
|
39 | - //TODO: Cache the file contents |
|
40 | - $config = parse_ini_file($this->filename, (bool)$this->nameSpace); |
|
41 | - |
|
42 | - if($config === false){ |
|
43 | - throw new INIParseException('Could not parse: ' . $this->filename, true); |
|
44 | - } |
|
45 | - |
|
46 | - if($this->nameSpace) { |
|
47 | - if(isset($config[$this->nameSpace])) { |
|
48 | - $config = $config[$this->nameSpace]; |
|
49 | - } else { |
|
50 | - throw new INIKeyNotFoundException(); |
|
51 | - } |
|
52 | - } |
|
53 | - |
|
54 | - return isset($config[$key]) ? $config[$key] : null; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param $key |
|
59 | - */ |
|
60 | - public function set($key){ |
|
61 | - //TODO write this |
|
62 | - } |
|
33 | + * @param $key |
|
34 | + * @return mixed |
|
35 | + * @throws INIKeyNotFoundException |
|
36 | + * @throws INIParseException |
|
37 | + */ |
|
38 | + public function get($key){ |
|
39 | + //TODO: Cache the file contents |
|
40 | + $config = parse_ini_file($this->filename, (bool)$this->nameSpace); |
|
41 | + |
|
42 | + if($config === false){ |
|
43 | + throw new INIParseException('Could not parse: ' . $this->filename, true); |
|
44 | + } |
|
45 | + |
|
46 | + if($this->nameSpace) { |
|
47 | + if(isset($config[$this->nameSpace])) { |
|
48 | + $config = $config[$this->nameSpace]; |
|
49 | + } else { |
|
50 | + throw new INIKeyNotFoundException(); |
|
51 | + } |
|
52 | + } |
|
53 | + |
|
54 | + return isset($config[$key]) ? $config[$key] : null; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param $key |
|
59 | + */ |
|
60 | + public function set($key){ |
|
61 | + //TODO write this |
|
62 | + } |
|
63 | 63 | } |