Passed
Push — master ( b70d6e...2597c3 )
by Alfred
01:53
created
ConfigManager.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -10,18 +10,18 @@  discard block
 block discarded – undo
10 10
 class ConfigManager
11 11
 {
12 12
     /**
13
-    * Chemin complet du fichier de configuration
14
-    */
13
+     * Chemin complet du fichier de configuration
14
+     */
15 15
     private $targetFile;
16 16
     private $Options = [];
17 17
     /**
18
-    * tableau multidimensionnel contenant les donnée de configuration, initialement
19
-    * chargées depuis le fichier
20
-    */
18
+     * tableau multidimensionnel contenant les donnée de configuration, initialement
19
+     * chargées depuis le fichier
20
+     */
21 21
     private $Config = [];
22 22
     /**
23
-    * processeurs de fichier pris en charge par l'application
24
-    */
23
+     * processeurs de fichier pris en charge par l'application
24
+     */
25 25
     private $availableDrivers = array('JSON', 'PHP','INI','YML');
26 26
 
27 27
     private $defaultSection = 'runtime';
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
             trigger_error($a->getMessage(),E_USER_ERROR);
48 48
         }
49 49
     }
50
- /**
51
-     * @param $section
52
-     * @param $item
53
-     * @return array|bool|mixed
54
-     */
50
+  /**
51
+   * @param $section
52
+   * @param $item
53
+   * @return array|bool|mixed
54
+   */
55 55
     public function get($section=null, $item=null)
56 56
     {
57 57
         if($item) $item = trim(strtolower($item));
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
         return $this->Config[$section][$item];
81 81
     }
82 82
 
83
- /**
84
-     * @param $section
85
-     * @param $item
86
-     * @param $value
87
-     * @return bool
88
-     */
83
+  /**
84
+   * @param $section
85
+   * @param $item
86
+   * @param $value
87
+   * @return bool
88
+   */
89 89
     public function set($section,$item=null,$value=null)
90 90
     { 
91 91
         ob_start();
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             case 1:
97 97
                 if(!is_array($arguments[0])) return false;
98 98
                 $item=array_change_key_case($arguments[0], CASE_LOWER); $section=null; $value=null;	
99
-		break;
99
+    break;
100 100
             case 2:
101 101
                 if(is_array($arguments[0])) return false;
102 102
                 $_arg = strtolower(trim($arguments[0]));
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
             $Options['driver'] = strtoupper(pathinfo($Options['filename'], PATHINFO_EXTENSION));
216 216
         else
217 217
             $Options['filename']= $Options['filename'].'.'.strtolower($default['driver']);
218
-	     if(!in_array($Options['driver'],$this->availableDrivers))
218
+        if(!in_array($Options['driver'],$this->availableDrivers))
219 219
             throw new Exception('ERROR: driver "'.$Options['driver'].'" not supported');
220
-	    $this->Options = array_merge($default,$Options);
220
+      $this->Options = array_merge($default,$Options);
221 221
         return $this->Options;
222 222
     }
223 223
     /**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         }
250 250
         return $path;
251 251
     }
252
-	  /**
252
+    /**
253 253
      * @param array $options
254 254
      * @return mixed
255 255
      */
@@ -286,15 +286,15 @@  discard block
 block discarded – undo
286 286
 /**
287 287
      * @return bool
288 288
      */
289
-     private function Save()
289
+      private function Save()
290
+    {
291
+  try {
292
+    if( !is_writeable( $this->targetFile ) )
290 293
     {
291
-	try {
292
-		if( !is_writeable( $this->targetFile ) )
293
-		{
294
-			if(@chmod($this->targetFile,0775))
295
-				throw new Exception('Cant write to file: '.$this->targetFile);
296
-		}
297
-	$content = null;
294
+      if(@chmod($this->targetFile,0775))
295
+        throw new Exception('Cant write to file: '.$this->targetFile);
296
+    }
297
+  $content = null;
298 298
         switch($this->Options['driver'])
299 299
         {
300 300
             case 'JSON':
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
                 break;
326 326
         }
327 327
         file_put_contents($this->targetFile, $content, LOCK_EX);
328
-	if(@chmod($this->targetFile,0644))
329
-		throw new Exception('Cant write to file: '.$this->targetFile);
330
-	    } 
331
-	     catch (Exception $e) 
332
-	     {  trigger_error($e->getMessage(),E_USER_ERROR);}
328
+  if(@chmod($this->targetFile,0644))
329
+    throw new Exception('Cant write to file: '.$this->targetFile);
330
+      } 
331
+        catch (Exception $e) 
332
+        {  trigger_error($e->getMessage(),E_USER_ERROR);}
333 333
         return true;
334 334
     }
335 335
     /**
Please login to merge, or discard this patch.