Completed
Branch master (3c175d)
by Alfred
03:21 queued 01:31
created
ConfigManager.php 1 patch
Indentation   +34 added lines, -34 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,13 +286,13 @@  discard block
 block discarded – undo
286 286
 /**
287 287
      * @return bool
288 288
      */
289
-     private function Save()
289
+      private function Save()
290 290
     {
291
-	try {
292
-		if( !is_writeable( $this->targetFile ) )
293
-			if(@chmod($this->targetFile,0775))
294
-				throw new Exception('Cant write to file: '.$this->targetFile);
295
-		       $content = null;
291
+  try {
292
+    if( !is_writeable( $this->targetFile ) )
293
+      if(@chmod($this->targetFile,0775))
294
+        throw new Exception('Cant write to file: '.$this->targetFile);
295
+            $content = null;
296 296
         switch($this->Options['driver'])
297 297
         {
298 298
             case 'JSON':
@@ -323,12 +323,12 @@  discard block
 block discarded – undo
323 323
                 break;
324 324
         }
325 325
         file_put_contents($this->targetFile, $content, LOCK_EX);
326
-	if( is_writeable( $this->targetFile ) )
327
-		if(@chmod($this->targetFile,0644))
328
-			throw new Exception('Cant write to file: '.$this->targetFile);
329
-	    } 
330
-	     catch (Exception $e) 
331
-	     {  trigger_error($e->getMessage(),E_USER_ERROR);}
326
+  if( is_writeable( $this->targetFile ) )
327
+    if(@chmod($this->targetFile,0644))
328
+      throw new Exception('Cant write to file: '.$this->targetFile);
329
+      } 
330
+        catch (Exception $e) 
331
+        {  trigger_error($e->getMessage(),E_USER_ERROR);}
332 332
         return true;
333 333
     }
334 334
     /**
Please login to merge, or discard this patch.