Passed
Push — dev ( 5d6178...724ebd )
by Marcin
19:40 queued 09:39
created
src/Util.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,59 +15,59 @@
 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 by value, assuming value is an array and contains `pri` key with integer (positive/negative)
59
-     * 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
-        // we now need to sort 'classes' node by priority
66
-        uasort($array, function($array_a, $array_b) {
67
-            $pri_a = $array_a['pri'] ?? 0;
68
-            $pri_b = $array_b['pri'] ?? 0;
57
+	/**
58
+	 * Sorts array by value, assuming value is an array and contains `pri` key with integer (positive/negative)
59
+	 * 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
+		// we now need to sort 'classes' node by priority
66
+		uasort($array, function($array_a, $array_b) {
67
+			$pri_a = $array_a['pri'] ?? 0;
68
+			$pri_b = $array_b['pri'] ?? 0;
69 69
 
70
-            return $pri_b <=> $pri_a;
71
-        });
72
-    }
70
+			return $pri_b <=> $pri_a;
71
+		});
72
+	}
73 73
 }
Please login to merge, or discard this patch.
src/ResponseBuilderServiceProvider.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -25,50 +25,50 @@
 block discarded – undo
25 25
 
26 26
 class ResponseBuilderServiceProvider extends ServiceProvider
27 27
 {
28
-    /**
29
-     * Register bindings in the container.
30
-     *
31
-     * @return void
32
-     */
33
-    public function register()
34
-    {
35
-        $this->mergeConfigFrom(
36
-            __DIR__ . '/../config/response_builder.php', 'response_builder'
37
-        );
38
-    }
28
+	/**
29
+	 * Register bindings in the container.
30
+	 *
31
+	 * @return void
32
+	 */
33
+	public function register()
34
+	{
35
+		$this->mergeConfigFrom(
36
+			__DIR__ . '/../config/response_builder.php', 'response_builder'
37
+		);
38
+	}
39 39
 
40
-    /**
41
-     * Sets up package resources
42
-     *
43
-     * @return void
44
-     */
45
-    public function boot()
46
-    {
47
-        $this->loadTranslationsFrom(__DIR__ . '/lang', 'response-builder');
40
+	/**
41
+	 * Sets up package resources
42
+	 *
43
+	 * @return void
44
+	 */
45
+	public function boot()
46
+	{
47
+		$this->loadTranslationsFrom(__DIR__ . '/lang', 'response-builder');
48 48
 
49
-        $source = __DIR__ . '/../config/response_builder.php';
50
-        $this->publishes([
51
-            $source => config_path('response_builder.php'),
52
-        ]);
53
-    }
49
+		$source = __DIR__ . '/../config/response_builder.php';
50
+		$this->publishes([
51
+			$source => config_path('response_builder.php'),
52
+		]);
53
+	}
54 54
 
55
-    /**
56
-     * Merge the given configuration with the existing configuration.
57
-     *
58
-     * @param string $path
59
-     * @param string $key
60
-     *
61
-     * @return void
62
-     */
63
-    protected function mergeConfigFrom($path, $key)
64
-    {
65
-        $defaults = require $path;
66
-        $config = $this->app['config']->get($key, []);
55
+	/**
56
+	 * Merge the given configuration with the existing configuration.
57
+	 *
58
+	 * @param string $path
59
+	 * @param string $key
60
+	 *
61
+	 * @return void
62
+	 */
63
+	protected function mergeConfigFrom($path, $key)
64
+	{
65
+		$defaults = require $path;
66
+		$config = $this->app['config']->get($key, []);
67 67
 
68
-        $merged_config = Util::mergeConfig($defaults, $config);
69
-        Util::sortArrayByPri($merged_config['classes']);
68
+		$merged_config = Util::mergeConfig($defaults, $config);
69
+		Util::sortArrayByPri($merged_config['classes']);
70 70
 
71
-        $this->app['config']->set($key, $merged_config);
72
-    }
71
+		$this->app['config']->set($key, $merged_config);
72
+	}
73 73
 
74 74
 }
Please login to merge, or discard this patch.