Passed
Push — master ( abee1f...edc958 )
by Kirill
03:08
created
src/Config/src/Loader/DirectoryLoader.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function has(string $section): bool
48 48
     {
49
-        foreach (static::LOADERS as $extension => $class) {
49
+        foreach (static::LOADERS as $extension => $class){
50 50
             $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension);
51
-            if (file_exists($filename)) {
51
+            if (file_exists($filename)){
52 52
                 return true;
53 53
             }
54 54
         }
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function load(string $section): array
63 63
     {
64
-        foreach (static::LOADERS as $extension => $class) {
64
+        foreach (static::LOADERS as $extension => $class){
65 65
             $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension);
66
-            if (!file_exists($filename)) {
66
+            if (!file_exists($filename)){
67 67
                 continue;
68 68
             }
69 69
 
70
-            try {
70
+            try{
71 71
                 return $this->getLoader($extension)->loadFile($section, $filename);
72
-            } catch (LoaderException $e) {
72
+            }catch (LoaderException $e){
73 73
                 throw new LoaderException("Unable to load config `{$section}`.", $e->getCode(), $e);
74 74
             }
75 75
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     private function getLoader(string $extension): FileLoaderInterface
85 85
     {
86
-        if (isset($this->loaders[$extension])) {
86
+        if (isset($this->loaders[$extension])){
87 87
             return $this->loaders[$extension];
88 88
         }
89 89
 
Please login to merge, or discard this patch.
src/Config/src/Loader/PhpLoader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@
 block discarded – undo
36 36
      */
37 37
     public function loadFile(string $section, string $filename): array
38 38
     {
39
-        try {
39
+        try{
40 40
             return ContainerScope::runScope($this->container, function () use ($filename) {
41 41
                 return (require $filename);
42 42
             });
43
-        } catch (\Throwable $e) {
43
+        }catch (\Throwable $e){
44 44
             throw new LoaderException($e->getMessage(), $e->getCode(), $e);
45 45
         }
46 46
     }
Please login to merge, or discard this patch.
src/Config/src/Loader/JsonLoader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         $content = file_get_contents($filename);
24 24
         $data = json_decode($content, true);
25 25
 
26
-        if (is_null($data)) {
26
+        if (is_null($data)){
27 27
             throw new LoaderException(json_last_error_msg(), json_last_error());
28 28
         }
29 29
 
Please login to merge, or discard this patch.
src/Config/src/ConfigManager.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function setDefaults(string $section, array $data): void
71 71
     {
72
-        if (isset($this->defaults[$section])) {
72
+        if (isset($this->defaults[$section])){
73 73
             throw new ConfiguratorException("Unable to set default config `{$section}` more than once.");
74 74
         }
75 75
 
76
-        if (isset($this->data[$section])) {
76
+        if (isset($this->data[$section])){
77 77
             throw new ConfigDeliveredException("Unable to set default config `{$section}`, config has been loaded.");
78 78
         }
79 79
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function modify(string $section, PatchInterface $patch): array
87 87
     {
88
-        if (isset($this->instances[$section])) {
89
-            if ($this->strict) {
88
+        if (isset($this->instances[$section])){
89
+            if ($this->strict){
90 90
                 throw new ConfigDeliveredException(
91 91
                     "Unable to patch config `{$section}`, config object has already been delivered."
92 92
                 );
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 
98 98
         $data = $this->getConfig($section);
99 99
 
100
-        try {
100
+        try{
101 101
             return $this->data[$section] = $patch->patch($data);
102
-        } catch (PatchException $e) {
102
+        }catch (PatchException $e){
103 103
             throw new PatchException("Unable to modify config `{$section}`.", $e->getCode(), $e);
104 104
         }
105 105
     }
@@ -109,18 +109,18 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function getConfig(string $section = null): array
111 111
     {
112
-        if (isset($this->data[$section])) {
112
+        if (isset($this->data[$section])){
113 113
             return $this->data[$section];
114 114
         }
115 115
 
116
-        if (isset($this->defaults[$section])) {
116
+        if (isset($this->defaults[$section])){
117 117
             $data = [];
118
-            if ($this->loader->has($section)) {
118
+            if ($this->loader->has($section)){
119 119
                 $data = $this->loader->load($section);
120 120
             }
121 121
 
122 122
             $data = array_merge($this->defaults[$section], $data);
123
-        } else {
123
+        }else{
124 124
             $data = $this->loader->load($section);
125 125
         }
126 126
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     public function createInjection(\ReflectionClass $class, string $context = null)
134 134
     {
135 135
         $config = $class->getConstant('CONFIG');
136
-        if (isset($this->instances[$config])) {
136
+        if (isset($this->instances[$config])){
137 137
             return $this->instances[$config];
138 138
         }
139 139
 
Please login to merge, or discard this patch.
src/Config/src/Patch/Set.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@
 block discarded – undo
45 45
      */
46 46
     public function patch(array $config): array
47 47
     {
48
-        try {
48
+        try{
49 49
             $target = &$this->dotGet($config, $this->key);
50 50
             $target = $this->value;
51
-        } catch (DotNotFoundException $e) {
51
+        }catch (DotNotFoundException $e){
52 52
             throw new PatchException($e->getMessage(), $e->getCode(), $e);
53 53
         }
54 54
 
Please login to merge, or discard this patch.
src/Config/src/Patch/Delete.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@
 block discarded – undo
45 45
      */
46 46
     public function patch(array $config): array
47 47
     {
48
-        try {
48
+        try{
49 49
             $target = &$this->dotGet($config, $this->position);
50 50
 
51
-            if ($this->key !== null) {
51
+            if ($this->key !== null){
52 52
                 unset($target[$this->key]);
53
-            } else {
54
-                foreach ($target as $key => $value) {
55
-                    if ($value === $this->value) {
53
+            }else{
54
+                foreach ($target as $key => $value){
55
+                    if ($value === $this->value){
56 56
                         unset($target[$key]);
57 57
                         break;
58 58
                     }
59 59
                 }
60 60
             }
61
-        } catch (DotNotFoundException $e) {
61
+        }catch (DotNotFoundException $e){
62 62
             // doing nothing when section not found
63 63
         }
64 64
 
Please login to merge, or discard this patch.
src/Config/src/Patch/Group.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
      */
33 33
     public function patch(array $config): array
34 34
     {
35
-        foreach ($this->patches as $patch) {
35
+        foreach ($this->patches as $patch){
36 36
             $config = $patch->patch($config);
37 37
         }
38 38
 
Please login to merge, or discard this patch.
src/Config/src/Patch/Append.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@
 block discarded – undo
46 46
      */
47 47
     public function patch(array $config): array
48 48
     {
49
-        try {
49
+        try{
50 50
             $target = &$this->dotGet($config, $this->position);
51 51
 
52
-            if ($this->key !== null) {
52
+            if ($this->key !== null){
53 53
                 $target[$this->key] = $this->value;
54
-            } else {
54
+            }else{
55 55
                 $target[] = $this->value;
56 56
             }
57
-        } catch (DotNotFoundException $e) {
57
+        }catch (DotNotFoundException $e){
58 58
             throw new PatchException($e->getMessage(), $e->getCode(), $e);
59 59
         }
60 60
 
Please login to merge, or discard this patch.
src/Config/src/Patch/Traits/DotTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
     private function &dotGet(array &$data, string $name)
24 24
     {
25 25
         //Generating path relative to a given name and prefix
26
-        $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name;
27
-        if (empty($path)) {
26
+        $path = (!empty($this->prefix) ? $this->prefix.'.' : '').$name;
27
+        if (empty($path)){
28 28
             return $data;
29 29
         }
30 30
 
31 31
         $path = explode('.', rtrim($path, '.'));
32
-        foreach ($path as $step) {
33
-            if (!is_array($data) || !array_key_exists($step, $data)) {
32
+        foreach ($path as $step){
33
+            if (!is_array($data) || !array_key_exists($step, $data)){
34 34
                 throw new DotNotFoundException("Unable to find config element '{$name}'.");
35 35
             }
36 36
             $data = &$data[$step];
Please login to merge, or discard this patch.