@@ -9,52 +9,52 @@ |
||
| 9 | 9 | * @package LunixREST\Configuration |
| 10 | 10 | */ |
| 11 | 11 | class INIConfiguration implements Configuration { |
| 12 | - /** |
|
| 13 | - * @var null |
|
| 14 | - */ |
|
| 15 | - protected $nameSpace; |
|
| 16 | - /** |
|
| 17 | - * @var |
|
| 18 | - */ |
|
| 19 | - protected $filename; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @param string $filename |
|
| 23 | - * @param string $nameSpace |
|
| 24 | - */ |
|
| 25 | - public function __construct($filename, $nameSpace = null){ |
|
| 26 | - $this->filename = $filename; |
|
| 27 | - $this->nameSpace = $nameSpace; |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @param $key |
|
| 32 | - * @return mixed |
|
| 33 | - * @throws INIKeyNotFoundException |
|
| 34 | - * @throws INIParseException |
|
| 35 | - */ |
|
| 36 | - public function get($key){ |
|
| 37 | - $config = parse_ini_file($this->filename, (bool)$this->nameSpace); |
|
| 38 | - |
|
| 39 | - if($config === false){ |
|
| 40 | - throw new INIParseException('Could not parse: ' . $this->filename, true); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - if($this->nameSpace) { |
|
| 44 | - if(isset($config[$this->nameSpace])) { |
|
| 45 | - $config = $config[$this->nameSpace]; |
|
| 46 | - } else { |
|
| 47 | - throw new INIKeyNotFoundException(); |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - return isset($config[$key]) ? $config[$key] : null; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @param $key |
|
| 56 | - */ |
|
| 57 | - public function set($key){ |
|
| 58 | - //TODO write this |
|
| 59 | - } |
|
| 12 | + /** |
|
| 13 | + * @var null |
|
| 14 | + */ |
|
| 15 | + protected $nameSpace; |
|
| 16 | + /** |
|
| 17 | + * @var |
|
| 18 | + */ |
|
| 19 | + protected $filename; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @param string $filename |
|
| 23 | + * @param string $nameSpace |
|
| 24 | + */ |
|
| 25 | + public function __construct($filename, $nameSpace = null){ |
|
| 26 | + $this->filename = $filename; |
|
| 27 | + $this->nameSpace = $nameSpace; |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @param $key |
|
| 32 | + * @return mixed |
|
| 33 | + * @throws INIKeyNotFoundException |
|
| 34 | + * @throws INIParseException |
|
| 35 | + */ |
|
| 36 | + public function get($key){ |
|
| 37 | + $config = parse_ini_file($this->filename, (bool)$this->nameSpace); |
|
| 38 | + |
|
| 39 | + if($config === false){ |
|
| 40 | + throw new INIParseException('Could not parse: ' . $this->filename, true); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + if($this->nameSpace) { |
|
| 44 | + if(isset($config[$this->nameSpace])) { |
|
| 45 | + $config = $config[$this->nameSpace]; |
|
| 46 | + } else { |
|
| 47 | + throw new INIKeyNotFoundException(); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + return isset($config[$key]) ? $config[$key] : null; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @param $key |
|
| 56 | + */ |
|
| 57 | + public function set($key){ |
|
| 58 | + //TODO write this |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -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 | } |
@@ -21,14 +21,17 @@ |
||
| 21 | 21 | $out = array(); |
| 22 | 22 | while(($line = fgets($this->file)) !== false) { |
| 23 | 23 | $line = trim(preg_replace('/#.*/', '', $line)); |
| 24 | - if(!$line) |
|
| 25 | - continue; |
|
| 24 | + if(!$line) { |
|
| 25 | + continue; |
|
| 26 | + } |
|
| 26 | 27 | $parts = preg_split('/\s+/', $line); |
| 27 | - if(count($parts) == 1) |
|
| 28 | - continue; |
|
| 28 | + if(count($parts) == 1) { |
|
| 29 | + continue; |
|
| 30 | + } |
|
| 29 | 31 | $type = array_shift($parts); |
| 30 | - foreach($parts as $part) |
|
| 31 | - $out[$part] = $type; |
|
| 32 | + foreach($parts as $part) { |
|
| 33 | + $out[$part] = $type; |
|
| 34 | + } |
|
| 32 | 35 | } |
| 33 | 36 | |
| 34 | 37 | $this->cache = $out; |