Passed
Push — master ( 94c8c0...745243 )
by Alain
03:42
created
src/ConfigFactory.php 2 patches
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -24,107 +24,107 @@
 block discarded – undo
24 24
 class ConfigFactory
25 25
 {
26 26
 
27
-    /**
28
-     * Cached contents of the config files.
29
-     *
30
-     * @since 0.4.3
31
-     *
32
-     * @var array
33
-     */
34
-    protected static $configFilesCache = [];
35
-
36
-    /**
37
-     * Create a new ConfigInterface object from a file.
38
-     *
39
-     * If a comma-separated list of files is provided, they are checked in sequence until the first one could be loaded
40
-     * successfully.
41
-     *
42
-     * @since 0.3.0
43
-     *
44
-     * @param string|array $_ List of files.
45
-     *
46
-     * @return ConfigInterface Instance of a ConfigInterface implementation.
47
-     */
48
-    public static function createFromFile($_)
49
-    {
50
-        $files = array_reverse(func_get_args());
51
-
52
-        if (is_array($files[0])) {
53
-            $files = $files[0];
54
-        }
55
-
56
-        while (count($files) > 0) {
57
-            try {
58
-                $file = array_pop($files);
59
-
60
-                if (! is_readable($file)) {
61
-                    continue;
62
-                }
63
-
64
-                if (! array_key_exists($file, static::$configFilesCache)) {
65
-                    static::$configFilesCache[$file] = Loader::load($file);
66
-                }
67
-
68
-                $config = static::createFromArray(
69
-                    static::$configFilesCache[$file]
70
-                );
71
-
72
-                if (null === $config) {
73
-                    continue;
74
-                }
75
-
76
-                return $config;
77
-            } catch (Exception $exception) {
78
-                // Fail silently and try next file.
79
-            }
80
-        }
81
-
82
-        return static::createFromArray([]);
83
-    }
84
-
85
-    /**
86
-     * Create a new ConfigInterface object from an array.
87
-     *
88
-     * @since 0.3.0
89
-     *
90
-     * @param array $array Array with configuration values.
91
-     *
92
-     * @return ConfigInterface Instance of a ConfigInterface implementation.
93
-     */
94
-    public static function createFromArray(array $array)
95
-    {
96
-        try {
97
-            return new Config($array);
98
-        } catch (Exception $exception) {
99
-            // Fail silently and try next file.
100
-        }
101
-
102
-        return null;
103
-    }
104
-
105
-    /**
106
-     * Create a new ConfigInterface object.
107
-     *
108
-     * Tries to deduce the correct creation method by inspecting the provided arguments.
109
-     *
110
-     * @since 0.3.0
111
-     *
112
-     * @param mixed $_ Array with configuration values.
113
-     *
114
-     * @return ConfigInterface Instance of a ConfigInterface implementation.
115
-     */
116
-    public static function create($_)
117
-    {
118
-        if (func_num_args() < 1) {
119
-            return static::createFromArray([]);
120
-        }
121
-
122
-        $arguments = func_get_args();
123
-
124
-        if (is_array($arguments[0]) && func_num_args() === 1) {
125
-            return static::createFromArray($arguments[0]);
126
-        }
127
-
128
-        return static::createFromFile($arguments);
129
-    }
27
+	/**
28
+	 * Cached contents of the config files.
29
+	 *
30
+	 * @since 0.4.3
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected static $configFilesCache = [];
35
+
36
+	/**
37
+	 * Create a new ConfigInterface object from a file.
38
+	 *
39
+	 * If a comma-separated list of files is provided, they are checked in sequence until the first one could be loaded
40
+	 * successfully.
41
+	 *
42
+	 * @since 0.3.0
43
+	 *
44
+	 * @param string|array $_ List of files.
45
+	 *
46
+	 * @return ConfigInterface Instance of a ConfigInterface implementation.
47
+	 */
48
+	public static function createFromFile($_)
49
+	{
50
+		$files = array_reverse(func_get_args());
51
+
52
+		if (is_array($files[0])) {
53
+			$files = $files[0];
54
+		}
55
+
56
+		while (count($files) > 0) {
57
+			try {
58
+				$file = array_pop($files);
59
+
60
+				if (! is_readable($file)) {
61
+					continue;
62
+				}
63
+
64
+				if (! array_key_exists($file, static::$configFilesCache)) {
65
+					static::$configFilesCache[$file] = Loader::load($file);
66
+				}
67
+
68
+				$config = static::createFromArray(
69
+					static::$configFilesCache[$file]
70
+				);
71
+
72
+				if (null === $config) {
73
+					continue;
74
+				}
75
+
76
+				return $config;
77
+			} catch (Exception $exception) {
78
+				// Fail silently and try next file.
79
+			}
80
+		}
81
+
82
+		return static::createFromArray([]);
83
+	}
84
+
85
+	/**
86
+	 * Create a new ConfigInterface object from an array.
87
+	 *
88
+	 * @since 0.3.0
89
+	 *
90
+	 * @param array $array Array with configuration values.
91
+	 *
92
+	 * @return ConfigInterface Instance of a ConfigInterface implementation.
93
+	 */
94
+	public static function createFromArray(array $array)
95
+	{
96
+		try {
97
+			return new Config($array);
98
+		} catch (Exception $exception) {
99
+			// Fail silently and try next file.
100
+		}
101
+
102
+		return null;
103
+	}
104
+
105
+	/**
106
+	 * Create a new ConfigInterface object.
107
+	 *
108
+	 * Tries to deduce the correct creation method by inspecting the provided arguments.
109
+	 *
110
+	 * @since 0.3.0
111
+	 *
112
+	 * @param mixed $_ Array with configuration values.
113
+	 *
114
+	 * @return ConfigInterface Instance of a ConfigInterface implementation.
115
+	 */
116
+	public static function create($_)
117
+	{
118
+		if (func_num_args() < 1) {
119
+			return static::createFromArray([]);
120
+		}
121
+
122
+		$arguments = func_get_args();
123
+
124
+		if (is_array($arguments[0]) && func_num_args() === 1) {
125
+			return static::createFromArray($arguments[0]);
126
+		}
127
+
128
+		return static::createFromFile($arguments);
129
+	}
130 130
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,11 +57,11 @@
 block discarded – undo
57 57
             try {
58 58
                 $file = array_pop($files);
59 59
 
60
-                if (! is_readable($file)) {
60
+                if ( ! is_readable($file)) {
61 61
                     continue;
62 62
                 }
63 63
 
64
-                if (! array_key_exists($file, static::$configFilesCache)) {
64
+                if ( ! array_key_exists($file, static::$configFilesCache)) {
65 65
                     static::$configFilesCache[$file] = Loader::load($file);
66 66
                 }
67 67
 
Please login to merge, or discard this patch.