Passed
Pull Request — master (#150)
by Marcin
08:03
created
src/Util.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,58 +15,58 @@
 block discarded – undo
15 15
  */
16 16
 final class Util
17 17
 {
18
-    /**
19
-     * Merges the configs together and takes multi-dimensional arrays into account.
20
-     * Support for multi-dimensional config array. Built-in config merge only supports flat arrays.
21
-     * Throws \RuntimeException if arrays stucture causes type conflics (i.e. you want to merge
22
-     * array with int).
23
-     *
24
-     * @param array $original Array to merge other array into. Usually default values to overwrite.
25
-     * @param array $merging  Array with items to be merged into $original, overriding (primitives) or merging
26
-     *                        (arrays) entries in destination array.
27
-     *
28
-     * @return array
29
-     *
30
-     * @throws \RuntimeException
31
-     */
32
-    public static function mergeConfig(array $original, array $merging): array
33
-    {
34
-        $array = $original;
35
-        foreach ($merging as $m_key => $m_val) {
36
-            if (\array_key_exists($m_key, $original)) {
37
-                $orig_type = \gettype($original[ $m_key ]);
38
-                $m_type = \gettype($m_val);
39
-                if ($orig_type !== $m_type) {
40
-                    throw new \RuntimeException(
41
-                        "Incompatible types. Cannot merge {$m_type} into {$orig_type} (key '{$m_key}').");
42
-                }
18
+	/**
19
+	 * Merges the configs together and takes multi-dimensional arrays into account.
20
+	 * Support for multi-dimensional config array. Built-in config merge only supports flat arrays.
21
+	 * Throws \RuntimeException if arrays stucture causes type conflics (i.e. you want to merge
22
+	 * array with int).
23
+	 *
24
+	 * @param array $original Array to merge other array into. Usually default values to overwrite.
25
+	 * @param array $merging  Array with items to be merged into $original, overriding (primitives) or merging
26
+	 *                        (arrays) entries in destination array.
27
+	 *
28
+	 * @return array
29
+	 *
30
+	 * @throws \RuntimeException
31
+	 */
32
+	public static function mergeConfig(array $original, array $merging): array
33
+	{
34
+		$array = $original;
35
+		foreach ($merging as $m_key => $m_val) {
36
+			if (\array_key_exists($m_key, $original)) {
37
+				$orig_type = \gettype($original[ $m_key ]);
38
+				$m_type = \gettype($m_val);
39
+				if ($orig_type !== $m_type) {
40
+					throw new \RuntimeException(
41
+						"Incompatible types. Cannot merge {$m_type} into {$orig_type} (key '{$m_key}').");
42
+				}
43 43
 
44
-                if (\is_array($merging[ $m_key ])) {
45
-                    $array[ $m_key ] = static::mergeConfig($original[ $m_key ], $m_val);
46
-                } else {
47
-                    $array[ $m_key ] = $m_val;
48
-                }
49
-            } else {
50
-                $array[ $m_key ] = $m_val;
51
-            }
52
-        }
44
+				if (\is_array($merging[ $m_key ])) {
45
+					$array[ $m_key ] = static::mergeConfig($original[ $m_key ], $m_val);
46
+				} else {
47
+					$array[ $m_key ] = $m_val;
48
+				}
49
+			} else {
50
+				$array[ $m_key ] = $m_val;
51
+			}
52
+		}
53 53
 
54
-        return $array;
55
-    }
54
+		return $array;
55
+	}
56 56
 
57
-    /**
58
-     * Sorts array (in place) by value, assuming value is an array and contains `pri` key with integer
59
-     * (positive/negative) value which is used for sorting higher -> lower priority.
60
-     *
61
-     * @param array &$array
62
-     */
63
-    public static function sortArrayByPri(array &$array): void
64
-    {
65
-        uasort($array, static function(array $array_a, array $array_b) {
66
-            $pri_a = $array_a['pri'] ?? 0;
67
-            $pri_b = $array_b['pri'] ?? 0;
57
+	/**
58
+	 * Sorts array (in place) by value, assuming value is an array and contains `pri` key with integer
59
+	 * (positive/negative) value which is used for sorting higher -> lower priority.
60
+	 *
61
+	 * @param array &$array
62
+	 */
63
+	public static function sortArrayByPri(array &$array): void
64
+	{
65
+		uasort($array, static function(array $array_a, array $array_b) {
66
+			$pri_a = $array_a['pri'] ?? 0;
67
+			$pri_b = $array_b['pri'] ?? 0;
68 68
 
69
-            return $pri_b <=> $pri_a;
70
-        });
71
-    }
69
+			return $pri_b <=> $pri_a;
70
+		});
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,20 +34,20 @@
 block discarded – undo
34 34
         $array = $original;
35 35
         foreach ($merging as $m_key => $m_val) {
36 36
             if (\array_key_exists($m_key, $original)) {
37
-                $orig_type = \gettype($original[ $m_key ]);
37
+                $orig_type = \gettype($original[$m_key]);
38 38
                 $m_type = \gettype($m_val);
39 39
                 if ($orig_type !== $m_type) {
40 40
                     throw new \RuntimeException(
41 41
                         "Incompatible types. Cannot merge {$m_type} into {$orig_type} (key '{$m_key}').");
42 42
                 }
43 43
 
44
-                if (\is_array($merging[ $m_key ])) {
45
-                    $array[ $m_key ] = static::mergeConfig($original[ $m_key ], $m_val);
44
+                if (\is_array($merging[$m_key])) {
45
+                    $array[$m_key] = static::mergeConfig($original[$m_key], $m_val);
46 46
                 } else {
47
-                    $array[ $m_key ] = $m_val;
47
+                    $array[$m_key] = $m_val;
48 48
                 }
49 49
             } else {
50
-                $array[ $m_key ] = $m_val;
50
+                $array[$m_key] = $m_val;
51 51
             }
52 52
         }
53 53
 
Please login to merge, or discard this patch.
src/ExceptionHandlers/HttpExceptionHandler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@
 block discarded – undo
42 42
 		$config = \array_replace($default_config, $user_config);
43 43
 
44 44
 		$http_code = $ex->getStatusCode();
45
-		$result = $config[ $http_code ] ?? null;
45
+		$result = $config[$http_code] ?? null;
46 46
 
47 47
 		// If we do not have dedicated entry fort this particular http_code,
48 48
 		// fall back to default value.
49 49
 		if ($result === null) {
50
-			$result = $config[ ResponseBuilder::KEY_DEFAULT ];
50
+			$result = $config[ResponseBuilder::KEY_DEFAULT];
51 51
 		}
52 52
 
53 53
 		// Some defaults to fall back to if not set in user config.
Please login to merge, or discard this patch.