@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | public function setUp(): void |
| 24 | 24 | { |
| 25 | 25 | exec('protoc 2>&1', $out); |
| 26 | - if (strpos(implode("\n", $out), '--php_out') === false) { |
|
| 26 | + if (strpos(implode("\n", $out), '--php_out') === false){ |
|
| 27 | 27 | $this->markTestSkipped('Protoc binary is missing'); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | $fs = new Files(); |
| 33 | 33 | |
| 34 | 34 | $this->runCommandDebug('grpc:generate', [ |
| 35 | - 'proto' => realpath($fs->normalizePath($this->app->dir('app') . 'proto/service.proto')) |
|
| 35 | + 'proto' => realpath($fs->normalizePath($this->app->dir('app').'proto/service.proto')) |
|
| 36 | 36 | ]); |
| 37 | 37 | |
| 38 | - $output = $this->app->dir('app') . 'src/Service/EchoService.php'; |
|
| 38 | + $output = $this->app->dir('app').'src/Service/EchoService.php'; |
|
| 39 | 39 | file_put_contents($output, GenerateTest::SERVICE); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $fs = new Files(); |
| 47 | 47 | |
| 48 | - if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) { |
|
| 49 | - $fs->deleteDirectory($this->app->dir('app') . 'src/Service'); |
|
| 48 | + if ($fs->isDirectory($this->app->dir('app').'src/Service')){ |
|
| 49 | + $fs->deleteDirectory($this->app->dir('app').'src/Service'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) { |
|
| 53 | - $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata'); |
|
| 52 | + if ($fs->isDirectory($this->app->dir('app').'src/GPBMetadata')){ |
|
| 53 | + $fs->deleteDirectory($this->app->dir('app').'src/GPBMetadata'); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $msg->setMsg('hello'); |
| 77 | 77 | |
| 78 | 78 | $w->shouldReceive('receive')->once()->with( |
| 79 | - \Mockery::on(function (&$context) { |
|
| 79 | + \Mockery::on(function (&$context){ |
|
| 80 | 80 | $context = '{ |
| 81 | 81 | "service": "service.Echo", |
| 82 | 82 | "method": "Ping", |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | )->andReturn($msg->serializeToString()); |
| 89 | 89 | |
| 90 | 90 | $w->shouldReceive('send')->once()->with( |
| 91 | - \Mockery::on(function ($out) { |
|
| 91 | + \Mockery::on(function ($out){ |
|
| 92 | 92 | $msg = new Message(); |
| 93 | 93 | $msg->mergeFromString($out); |
| 94 | 94 | $this->assertSame('hello', $msg->getMsg()); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | // one command only |
| 102 | 102 | $w->shouldReceive('receive')->once()->with( |
| 103 | - \Mockery::on(function (&$context) { |
|
| 103 | + \Mockery::on(function (&$context){ |
|
| 104 | 104 | $context = null; |
| 105 | 105 | return true; |
| 106 | 106 | }) |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $msg->setMsg('hello'); |
| 121 | 121 | |
| 122 | 122 | $w->shouldReceive('receive')->once()->with( |
| 123 | - \Mockery::on(function (&$context) { |
|
| 123 | + \Mockery::on(function (&$context){ |
|
| 124 | 124 | $context = '{ |
| 125 | 125 | "service": "service.Echo", |
| 126 | 126 | "method": "Invalid", |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | )->andReturn($msg->serializeToString()); |
| 133 | 133 | |
| 134 | 134 | $w->shouldReceive('error')->once()->with( |
| 135 | - \Mockery::on(function ($out) { |
|
| 135 | + \Mockery::on(function ($out){ |
|
| 136 | 136 | $this->assertStringContainsString('Method `Invalid` not found', $out); |
| 137 | 137 | return true; |
| 138 | 138 | }) |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | // one command only |
| 142 | 142 | $w->shouldReceive('receive')->once()->with( |
| 143 | - \Mockery::on(function (&$context) { |
|
| 143 | + \Mockery::on(function (&$context){ |
|
| 144 | 144 | $context = null; |
| 145 | 145 | return true; |
| 146 | 146 | }) |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | public function setUp(): void |
| 24 | 24 | { |
| 25 | 25 | exec('protoc 2>&1', $out); |
| 26 | - if (strpos(implode("\n", $out), '--php_out') === false) { |
|
| 26 | + if (strpos(implode("\n", $out), '--php_out') === false) |
|
| 27 | + { |
|
| 27 | 28 | $this->markTestSkipped('Protoc binary is missing'); |
| 28 | 29 | } |
| 29 | 30 | |
@@ -45,11 +46,13 @@ discard block |
||
| 45 | 46 | |
| 46 | 47 | $fs = new Files(); |
| 47 | 48 | |
| 48 | - if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) { |
|
| 49 | + if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) |
|
| 50 | + { |
|
| 49 | 51 | $fs->deleteDirectory($this->app->dir('app') . 'src/Service'); |
| 50 | 52 | } |
| 51 | 53 | |
| 52 | - if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) { |
|
| 54 | + if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) |
|
| 55 | + { |
|
| 53 | 56 | $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata'); |
| 54 | 57 | } |
| 55 | 58 | } |
@@ -76,7 +79,8 @@ discard block |
||
| 76 | 79 | $msg->setMsg('hello'); |
| 77 | 80 | |
| 78 | 81 | $w->shouldReceive('receive')->once()->with( |
| 79 | - \Mockery::on(function (&$context) { |
|
| 82 | + \Mockery::on(function (&$context) |
|
| 83 | + { |
|
| 80 | 84 | $context = '{ |
| 81 | 85 | "service": "service.Echo", |
| 82 | 86 | "method": "Ping", |
@@ -88,7 +92,8 @@ discard block |
||
| 88 | 92 | )->andReturn($msg->serializeToString()); |
| 89 | 93 | |
| 90 | 94 | $w->shouldReceive('send')->once()->with( |
| 91 | - \Mockery::on(function ($out) { |
|
| 95 | + \Mockery::on(function ($out) |
|
| 96 | + { |
|
| 92 | 97 | $msg = new Message(); |
| 93 | 98 | $msg->mergeFromString($out); |
| 94 | 99 | $this->assertSame('hello', $msg->getMsg()); |
@@ -100,7 +105,8 @@ discard block |
||
| 100 | 105 | |
| 101 | 106 | // one command only |
| 102 | 107 | $w->shouldReceive('receive')->once()->with( |
| 103 | - \Mockery::on(function (&$context) { |
|
| 108 | + \Mockery::on(function (&$context) |
|
| 109 | + { |
|
| 104 | 110 | $context = null; |
| 105 | 111 | return true; |
| 106 | 112 | }) |
@@ -120,7 +126,8 @@ discard block |
||
| 120 | 126 | $msg->setMsg('hello'); |
| 121 | 127 | |
| 122 | 128 | $w->shouldReceive('receive')->once()->with( |
| 123 | - \Mockery::on(function (&$context) { |
|
| 129 | + \Mockery::on(function (&$context) |
|
| 130 | + { |
|
| 124 | 131 | $context = '{ |
| 125 | 132 | "service": "service.Echo", |
| 126 | 133 | "method": "Invalid", |
@@ -132,7 +139,8 @@ discard block |
||
| 132 | 139 | )->andReturn($msg->serializeToString()); |
| 133 | 140 | |
| 134 | 141 | $w->shouldReceive('error')->once()->with( |
| 135 | - \Mockery::on(function ($out) { |
|
| 142 | + \Mockery::on(function ($out) |
|
| 143 | + { |
|
| 136 | 144 | $this->assertStringContainsString('Method `Invalid` not found', $out); |
| 137 | 145 | return true; |
| 138 | 146 | }) |
@@ -140,7 +148,8 @@ discard block |
||
| 140 | 148 | |
| 141 | 149 | // one command only |
| 142 | 150 | $w->shouldReceive('receive')->once()->with( |
| 143 | - \Mockery::on(function (&$context) { |
|
| 151 | + \Mockery::on(function (&$context) |
|
| 152 | + { |
|
| 144 | 153 | $context = null; |
| 145 | 154 | return true; |
| 146 | 155 | }) |
@@ -46,9 +46,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -46,9 +46,11 @@ discard block |
||
| 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 | 51 | $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension); |
| 51 | - if (file_exists($filename)) { |
|
| 52 | + if (file_exists($filename)) |
|
| 53 | + { |
|
| 52 | 54 | return true; |
| 53 | 55 | } |
| 54 | 56 | } |
@@ -61,15 +63,20 @@ discard block |
||
| 61 | 63 | */ |
| 62 | 64 | public function load(string $section): array |
| 63 | 65 | { |
| 64 | - foreach (static::LOADERS as $extension => $class) { |
|
| 66 | + foreach (static::LOADERS as $extension => $class) |
|
| 67 | + { |
|
| 65 | 68 | $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension); |
| 66 | - if (!file_exists($filename)) { |
|
| 69 | + if (!file_exists($filename)) |
|
| 70 | + { |
|
| 67 | 71 | continue; |
| 68 | 72 | } |
| 69 | 73 | |
| 70 | - try { |
|
| 74 | + try |
|
| 75 | + { |
|
| 71 | 76 | return $this->getLoader($extension)->loadFile($section, $filename); |
| 72 | - } catch (LoaderException $e) { |
|
| 77 | + } |
|
| 78 | + catch (LoaderException $e) |
|
| 79 | + { |
|
| 73 | 80 | throw new LoaderException("Unable to load config `{$section}`.", $e->getCode(), $e); |
| 74 | 81 | } |
| 75 | 82 | } |
@@ -83,7 +90,8 @@ discard block |
||
| 83 | 90 | */ |
| 84 | 91 | private function getLoader(string $extension): FileLoaderInterface |
| 85 | 92 | { |
| 86 | - if (isset($this->loaders[$extension])) { |
|
| 93 | + if (isset($this->loaders[$extension])) |
|
| 94 | + { |
|
| 87 | 95 | return $this->loaders[$extension]; |
| 88 | 96 | } |
| 89 | 97 | |
@@ -36,11 +36,11 @@ |
||
| 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 | } |
@@ -36,11 +36,15 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | public function loadFile(string $section, string $filename): array |
| 38 | 38 | { |
| 39 | - try { |
|
| 40 | - return ContainerScope::runScope($this->container, function () use ($filename) { |
|
| 39 | + try |
|
| 40 | + { |
|
| 41 | + return ContainerScope::runScope($this->container, function () use ($filename) |
|
| 42 | + { |
|
| 41 | 43 | return (require $filename); |
| 42 | 44 | }); |
| 43 | - } catch (\Throwable $e) { |
|
| 45 | + } |
|
| 46 | + catch (\Throwable $e) |
|
| 47 | + { |
|
| 44 | 48 | throw new LoaderException($e->getMessage(), $e->getCode(), $e); |
| 45 | 49 | } |
| 46 | 50 | } |
@@ -23,7 +23,7 @@ |
||
| 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 | |
@@ -23,7 +23,8 @@ |
||
| 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 | 28 | throw new LoaderException(json_last_error_msg(), json_last_error()); |
| 28 | 29 | } |
| 29 | 30 | |
@@ -69,11 +69,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -69,11 +69,13 @@ discard block |
||
| 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 | 74 | throw new ConfiguratorException("Unable to set default config `{$section}` more than once."); |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | - if (isset($this->data[$section])) { |
|
| 77 | + if (isset($this->data[$section])) |
|
| 78 | + { |
|
| 77 | 79 | throw new ConfigDeliveredException("Unable to set default config `{$section}`, config has been loaded."); |
| 78 | 80 | } |
| 79 | 81 | |
@@ -85,8 +87,10 @@ discard block |
||
| 85 | 87 | */ |
| 86 | 88 | public function modify(string $section, PatchInterface $patch): array |
| 87 | 89 | { |
| 88 | - if (isset($this->instances[$section])) { |
|
| 89 | - if ($this->strict) { |
|
| 90 | + if (isset($this->instances[$section])) |
|
| 91 | + { |
|
| 92 | + if ($this->strict) |
|
| 93 | + { |
|
| 90 | 94 | throw new ConfigDeliveredException( |
| 91 | 95 | "Unable to patch config `{$section}`, config object has already been delivered." |
| 92 | 96 | ); |
@@ -97,9 +101,12 @@ discard block |
||
| 97 | 101 | |
| 98 | 102 | $data = $this->getConfig($section); |
| 99 | 103 | |
| 100 | - try { |
|
| 104 | + try |
|
| 105 | + { |
|
| 101 | 106 | return $this->data[$section] = $patch->patch($data); |
| 102 | - } catch (PatchException $e) { |
|
| 107 | + } |
|
| 108 | + catch (PatchException $e) |
|
| 109 | + { |
|
| 103 | 110 | throw new PatchException("Unable to modify config `{$section}`.", $e->getCode(), $e); |
| 104 | 111 | } |
| 105 | 112 | } |
@@ -109,18 +116,23 @@ discard block |
||
| 109 | 116 | */ |
| 110 | 117 | public function getConfig(string $section = null): array |
| 111 | 118 | { |
| 112 | - if (isset($this->data[$section])) { |
|
| 119 | + if (isset($this->data[$section])) |
|
| 120 | + { |
|
| 113 | 121 | return $this->data[$section]; |
| 114 | 122 | } |
| 115 | 123 | |
| 116 | - if (isset($this->defaults[$section])) { |
|
| 124 | + if (isset($this->defaults[$section])) |
|
| 125 | + { |
|
| 117 | 126 | $data = []; |
| 118 | - if ($this->loader->has($section)) { |
|
| 127 | + if ($this->loader->has($section)) |
|
| 128 | + { |
|
| 119 | 129 | $data = $this->loader->load($section); |
| 120 | 130 | } |
| 121 | 131 | |
| 122 | 132 | $data = array_merge($this->defaults[$section], $data); |
| 123 | - } else { |
|
| 133 | + } |
|
| 134 | + else |
|
| 135 | + { |
|
| 124 | 136 | $data = $this->loader->load($section); |
| 125 | 137 | } |
| 126 | 138 | |
@@ -133,7 +145,8 @@ discard block |
||
| 133 | 145 | public function createInjection(\ReflectionClass $class, string $context = null) |
| 134 | 146 | { |
| 135 | 147 | $config = $class->getConstant('CONFIG'); |
| 136 | - if (isset($this->instances[$config])) { |
|
| 148 | + if (isset($this->instances[$config])) |
|
| 149 | + { |
|
| 137 | 150 | return $this->instances[$config]; |
| 138 | 151 | } |
| 139 | 152 | |
@@ -45,10 +45,10 @@ |
||
| 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 | |
@@ -45,10 +45,13 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public function patch(array $config): array |
| 47 | 47 | { |
| 48 | - try { |
|
| 48 | + try |
|
| 49 | + { |
|
| 49 | 50 | $target = &$this->dotGet($config, $this->key); |
| 50 | 51 | $target = $this->value; |
| 51 | - } catch (DotNotFoundException $e) { |
|
| 52 | + } |
|
| 53 | + catch (DotNotFoundException $e) |
|
| 54 | + { |
|
| 52 | 55 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
| 53 | 56 | } |
| 54 | 57 | |
@@ -45,20 +45,20 @@ |
||
| 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 | |
@@ -45,20 +45,28 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public function patch(array $config): array |
| 47 | 47 | { |
| 48 | - try { |
|
| 48 | + try |
|
| 49 | + { |
|
| 49 | 50 | $target = &$this->dotGet($config, $this->position); |
| 50 | 51 | |
| 51 | - if ($this->key !== null) { |
|
| 52 | + if ($this->key !== null) |
|
| 53 | + { |
|
| 52 | 54 | unset($target[$this->key]); |
| 53 | - } else { |
|
| 54 | - foreach ($target as $key => $value) { |
|
| 55 | - if ($value === $this->value) { |
|
| 55 | + } |
|
| 56 | + else |
|
| 57 | + { |
|
| 58 | + foreach ($target as $key => $value) |
|
| 59 | + { |
|
| 60 | + if ($value === $this->value) |
|
| 61 | + { |
|
| 56 | 62 | unset($target[$key]); |
| 57 | 63 | break; |
| 58 | 64 | } |
| 59 | 65 | } |
| 60 | 66 | } |
| 61 | - } catch (DotNotFoundException $e) { |
|
| 67 | + } |
|
| 68 | + catch (DotNotFoundException $e) |
|
| 69 | + { |
|
| 62 | 70 | // doing nothing when section not found |
| 63 | 71 | } |
| 64 | 72 | |
@@ -32,7 +32,7 @@ |
||
| 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 | |
@@ -32,7 +32,8 @@ |
||
| 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 | 37 | $config = $patch->patch($config); |
| 37 | 38 | } |
| 38 | 39 | |
@@ -46,15 +46,15 @@ |
||
| 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 | |
@@ -46,15 +46,21 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function patch(array $config): array |
| 48 | 48 | { |
| 49 | - try { |
|
| 49 | + try |
|
| 50 | + { |
|
| 50 | 51 | $target = &$this->dotGet($config, $this->position); |
| 51 | 52 | |
| 52 | - if ($this->key !== null) { |
|
| 53 | + if ($this->key !== null) |
|
| 54 | + { |
|
| 53 | 55 | $target[$this->key] = $this->value; |
| 54 | - } else { |
|
| 56 | + } |
|
| 57 | + else |
|
| 58 | + { |
|
| 55 | 59 | $target[] = $this->value; |
| 56 | 60 | } |
| 57 | - } catch (DotNotFoundException $e) { |
|
| 61 | + } |
|
| 62 | + catch (DotNotFoundException $e) |
|
| 63 | + { |
|
| 58 | 64 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
| 59 | 65 | } |
| 60 | 66 | |