@@ -26,8 +26,8 @@ |
||
| 26 | 26 | $builder = $mapper->buildSchema($locator); |
| 27 | 27 | $filters = array_keys($builder->buildSchema()); |
| 28 | 28 | |
| 29 | - if ($this->isVerbose()) { |
|
| 30 | - foreach ($filters as $name) { |
|
| 29 | + if ($this->isVerbose()){ |
|
| 30 | + foreach ($filters as $name){ |
|
| 31 | 31 | $this->sprintf("<info>[filter]</info> %s\n", $name); |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -26,8 +26,10 @@ |
||
| 26 | 26 | $builder = $mapper->buildSchema($locator); |
| 27 | 27 | $filters = array_keys($builder->buildSchema()); |
| 28 | 28 | |
| 29 | - if ($this->isVerbose()) { |
|
| 30 | - foreach ($filters as $name) { |
|
| 29 | + if ($this->isVerbose()) |
|
| 30 | + { |
|
| 31 | + foreach ($filters as $name) |
|
| 32 | + { |
|
| 31 | 33 | $this->sprintf("<info>[filter]</info> %s\n", $name); |
| 32 | 34 | } |
| 33 | 35 | } |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function perform(Publisher $publisher, FilesInterface $files, DirectoriesInterface $directories) |
| 40 | 40 | { |
| 41 | - switch ($this->argument('type')) { |
|
| 41 | + switch ($this->argument('type')){ |
|
| 42 | 42 | case 'replace': |
| 43 | 43 | case 'follow': |
| 44 | - if ($this->isDirectory()) { |
|
| 44 | + if ($this->isDirectory()){ |
|
| 45 | 45 | $this->sprintf( |
| 46 | 46 | "<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>", |
| 47 | 47 | $this->getSource($files, $directories), |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $this->getMergeMode(), |
| 55 | 55 | $this->getFileMode() |
| 56 | 56 | ); |
| 57 | - } else { |
|
| 57 | + }else{ |
|
| 58 | 58 | $this->sprintf( |
| 59 | 59 | "<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>", |
| 60 | 60 | $this->getSource($files, $directories), |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | private function getSource(FilesInterface $files, DirectoriesInterface $directories): ?string |
| 93 | 93 | { |
| 94 | - if (!$this->isDirectory()) { |
|
| 94 | + if (!$this->isDirectory()){ |
|
| 95 | 95 | return $files->normalizePath($this->argument('source')); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
| 107 | 107 | { |
| 108 | 108 | $target = $this->argument('target'); |
| 109 | - foreach ($directories->getAll() as $alias => $value) { |
|
| 109 | + foreach ($directories->getAll() as $alias => $value){ |
|
| 110 | 110 | $target = str_replace("@{$alias}", $value, $target); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | private function isDirectory(): bool |
| 120 | 120 | { |
| 121 | - if ($this->argument('type') == 'ensure') { |
|
| 121 | + if ($this->argument('type') == 'ensure'){ |
|
| 122 | 122 | return true; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if (strpos($this->argument('source'), '*') !== false) { |
|
| 125 | + if (strpos($this->argument('source'), '*') !== false){ |
|
| 126 | 126 | return true; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function getMergeMode(): string |
| 136 | 136 | { |
| 137 | - switch ($this->argument('type')) { |
|
| 137 | + switch ($this->argument('type')){ |
|
| 138 | 138 | case 'follow': |
| 139 | 139 | return PublisherInterface::FOLLOW; |
| 140 | 140 | case 'replace': |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | private function getFileMode(): int |
| 151 | 151 | { |
| 152 | - switch ($this->argument('mode')) { |
|
| 152 | + switch ($this->argument('mode')){ |
|
| 153 | 153 | case 'readonly': |
| 154 | 154 | return FilesInterface::READONLY; |
| 155 | 155 | case 'runtime': |
@@ -38,10 +38,12 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function perform(Publisher $publisher, FilesInterface $files, DirectoriesInterface $directories) |
| 40 | 40 | { |
| 41 | - switch ($this->argument('type')) { |
|
| 41 | + switch ($this->argument('type')) |
|
| 42 | + { |
|
| 42 | 43 | case 'replace': |
| 43 | 44 | case 'follow': |
| 44 | - if ($this->isDirectory()) { |
|
| 45 | + if ($this->isDirectory()) |
|
| 46 | + { |
|
| 45 | 47 | $this->sprintf( |
| 46 | 48 | "<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>", |
| 47 | 49 | $this->getSource($files, $directories), |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | $this->getMergeMode(), |
| 55 | 57 | $this->getFileMode() |
| 56 | 58 | ); |
| 57 | - } else { |
|
| 59 | + } |
|
| 60 | + else |
|
| 61 | + { |
|
| 58 | 62 | $this->sprintf( |
| 59 | 63 | "<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>", |
| 60 | 64 | $this->getSource($files, $directories), |
@@ -91,7 +95,8 @@ discard block |
||
| 91 | 95 | */ |
| 92 | 96 | private function getSource(FilesInterface $files, DirectoriesInterface $directories): ?string |
| 93 | 97 | { |
| 94 | - if (!$this->isDirectory()) { |
|
| 98 | + if (!$this->isDirectory()) |
|
| 99 | + { |
|
| 95 | 100 | return $files->normalizePath($this->argument('source')); |
| 96 | 101 | } |
| 97 | 102 | |
@@ -106,7 +111,8 @@ discard block |
||
| 106 | 111 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
| 107 | 112 | { |
| 108 | 113 | $target = $this->argument('target'); |
| 109 | - foreach ($directories->getAll() as $alias => $value) { |
|
| 114 | + foreach ($directories->getAll() as $alias => $value) |
|
| 115 | + { |
|
| 110 | 116 | $target = str_replace("@{$alias}", $value, $target); |
| 111 | 117 | } |
| 112 | 118 | |
@@ -118,11 +124,13 @@ discard block |
||
| 118 | 124 | */ |
| 119 | 125 | private function isDirectory(): bool |
| 120 | 126 | { |
| 121 | - if ($this->argument('type') == 'ensure') { |
|
| 127 | + if ($this->argument('type') == 'ensure') |
|
| 128 | + { |
|
| 122 | 129 | return true; |
| 123 | 130 | } |
| 124 | 131 | |
| 125 | - if (strpos($this->argument('source'), '*') !== false) { |
|
| 132 | + if (strpos($this->argument('source'), '*') !== false) |
|
| 133 | + { |
|
| 126 | 134 | return true; |
| 127 | 135 | } |
| 128 | 136 | |
@@ -134,7 +142,8 @@ discard block |
||
| 134 | 142 | */ |
| 135 | 143 | private function getMergeMode(): string |
| 136 | 144 | { |
| 137 | - switch ($this->argument('type')) { |
|
| 145 | + switch ($this->argument('type')) |
|
| 146 | + { |
|
| 138 | 147 | case 'follow': |
| 139 | 148 | return PublisherInterface::FOLLOW; |
| 140 | 149 | case 'replace': |
@@ -149,7 +158,8 @@ discard block |
||
| 149 | 158 | */ |
| 150 | 159 | private function getFileMode(): int |
| 151 | 160 | { |
| 152 | - switch ($this->argument('mode')) { |
|
| 161 | + switch ($this->argument('mode')) |
|
| 162 | + { |
|
| 153 | 163 | case 'readonly': |
| 154 | 164 | return FilesInterface::READONLY; |
| 155 | 165 | case 'runtime': |
@@ -26,20 +26,20 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function perform(ViewsConfig $config, FilesInterface $files) |
| 28 | 28 | { |
| 29 | - if (!$files->exists($config->cacheDirectory())) { |
|
| 29 | + if (!$files->exists($config->cacheDirectory())){ |
|
| 30 | 30 | $this->writeln("Cache directory is missing, no cache to be cleaned."); |
| 31 | 31 | |
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ($this->isVerbose()) { |
|
| 35 | + if ($this->isVerbose()){ |
|
| 36 | 36 | $this->writeln("<info>Cleaning view cache:</info>"); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - foreach ($files->getFiles($config->cacheDirectory()) as $filename) { |
|
| 40 | - try { |
|
| 39 | + foreach ($files->getFiles($config->cacheDirectory()) as $filename){ |
|
| 40 | + try{ |
|
| 41 | 41 | $files->delete($filename); |
| 42 | - } catch (\Throwable $e) { |
|
| 42 | + }catch (\Throwable $e){ |
|
| 43 | 43 | $this->sprintf("<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
| 44 | 44 | $files->relativePath($filename, $config->cacheDirectory()), |
| 45 | 45 | $e->getMessage() |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | continue; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if ($this->isVerbose()) { |
|
| 51 | + if ($this->isVerbose()){ |
|
| 52 | 52 | $this->sprintf( |
| 53 | 53 | "<fg=green>[deleted]</fg=green> `%s`\n", |
| 54 | 54 | $files->relativePath($filename, $config->cacheDirectory()) |
@@ -26,20 +26,26 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function perform(ViewsConfig $config, FilesInterface $files) |
| 28 | 28 | { |
| 29 | - if (!$files->exists($config->cacheDirectory())) { |
|
| 29 | + if (!$files->exists($config->cacheDirectory())) |
|
| 30 | + { |
|
| 30 | 31 | $this->writeln("Cache directory is missing, no cache to be cleaned."); |
| 31 | 32 | |
| 32 | 33 | return; |
| 33 | 34 | } |
| 34 | 35 | |
| 35 | - if ($this->isVerbose()) { |
|
| 36 | + if ($this->isVerbose()) |
|
| 37 | + { |
|
| 36 | 38 | $this->writeln("<info>Cleaning view cache:</info>"); |
| 37 | 39 | } |
| 38 | 40 | |
| 39 | - foreach ($files->getFiles($config->cacheDirectory()) as $filename) { |
|
| 40 | - try { |
|
| 41 | + foreach ($files->getFiles($config->cacheDirectory()) as $filename) |
|
| 42 | + { |
|
| 43 | + try |
|
| 44 | + { |
|
| 41 | 45 | $files->delete($filename); |
| 42 | - } catch (\Throwable $e) { |
|
| 46 | + } |
|
| 47 | + catch (\Throwable $e) |
|
| 48 | + { |
|
| 43 | 49 | $this->sprintf("<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
| 44 | 50 | $files->relativePath($filename, $config->cacheDirectory()), |
| 45 | 51 | $e->getMessage() |
@@ -48,7 +54,8 @@ discard block |
||
| 48 | 54 | continue; |
| 49 | 55 | } |
| 50 | 56 | |
| 51 | - if ($this->isVerbose()) { |
|
| 57 | + if ($this->isVerbose()) |
|
| 58 | + { |
|
| 52 | 59 | $this->sprintf( |
| 53 | 60 | "<fg=green>[deleted]</fg=green> `%s`\n", |
| 54 | 61 | $files->relativePath($filename, $config->cacheDirectory()) |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $generator = new ContextGenerator($views->getContext()); |
| 34 | 34 | |
| 35 | - foreach ($generator->generate() as $context) { |
|
| 36 | - foreach ($views->getEngines() as $engine) { |
|
| 35 | + foreach ($generator->generate() as $context){ |
|
| 36 | + foreach ($views->getEngines() as $engine){ |
|
| 37 | 37 | $this->compile($engine, $context); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | $this->describeContext($context) |
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | - foreach ($engine->getLoader()->list() as $path) { |
|
| 57 | - try { |
|
| 56 | + foreach ($engine->getLoader()->list() as $path){ |
|
| 57 | + try{ |
|
| 58 | 58 | $start = microtime(true); |
| 59 | 59 | $engine->reset($path, $context); |
| 60 | 60 | $engine->compile($path, $context); |
| 61 | 61 | |
| 62 | - if ($this->isVerbose()) { |
|
| 62 | + if ($this->isVerbose()){ |
|
| 63 | 63 | $this->sprintf("<info>•</info> %s", $path); |
| 64 | 64 | } |
| 65 | - } catch (\Throwable $e) { |
|
| 66 | - if ($this->isVerbose()) { |
|
| 65 | + }catch (\Throwable $e){ |
|
| 66 | + if ($this->isVerbose()){ |
|
| 67 | 67 | $this->sprintf( |
| 68 | 68 | "<fg=red>•</fg=red> %s: <fg=red>%s at line %s</fg=red>", |
| 69 | 69 | $path, |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | continue; |
| 75 | - } finally { |
|
| 76 | - if ($this->isVerbose()) { |
|
| 75 | + }finally{ |
|
| 76 | + if ($this->isVerbose()){ |
|
| 77 | 77 | $this->sprintf( |
| 78 | 78 | " %s[%s ms]%s\n", |
| 79 | 79 | Color::GRAY, |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ($this->isVerbose()) { |
|
| 88 | - if (empty($path)) { |
|
| 87 | + if ($this->isVerbose()){ |
|
| 88 | + if (empty($path)){ |
|
| 89 | 89 | $this->writeln("• no views found"); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | $values = []; |
| 103 | 103 | |
| 104 | - foreach ($context->getDependencies() as $dependency) { |
|
| 104 | + foreach ($context->getDependencies() as $dependency){ |
|
| 105 | 105 | $values[] = sprintf( |
| 106 | 106 | "%s%s%s:%s%s%s", |
| 107 | 107 | Color::LIGHT_WHITE, |
@@ -32,8 +32,10 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $generator = new ContextGenerator($views->getContext()); |
| 34 | 34 | |
| 35 | - foreach ($generator->generate() as $context) { |
|
| 36 | - foreach ($views->getEngines() as $engine) { |
|
| 35 | + foreach ($generator->generate() as $context) |
|
| 36 | + { |
|
| 37 | + foreach ($views->getEngines() as $engine) |
|
| 38 | + { |
|
| 37 | 39 | $this->compile($engine, $context); |
| 38 | 40 | } |
| 39 | 41 | } |
@@ -53,17 +55,23 @@ discard block |
||
| 53 | 55 | $this->describeContext($context) |
| 54 | 56 | ); |
| 55 | 57 | |
| 56 | - foreach ($engine->getLoader()->list() as $path) { |
|
| 57 | - try { |
|
| 58 | + foreach ($engine->getLoader()->list() as $path) |
|
| 59 | + { |
|
| 60 | + try |
|
| 61 | + { |
|
| 58 | 62 | $start = microtime(true); |
| 59 | 63 | $engine->reset($path, $context); |
| 60 | 64 | $engine->compile($path, $context); |
| 61 | 65 | |
| 62 | - if ($this->isVerbose()) { |
|
| 66 | + if ($this->isVerbose()) |
|
| 67 | + { |
|
| 63 | 68 | $this->sprintf("<info>•</info> %s", $path); |
| 64 | 69 | } |
| 65 | - } catch (\Throwable $e) { |
|
| 66 | - if ($this->isVerbose()) { |
|
| 70 | + } |
|
| 71 | + catch (\Throwable $e) |
|
| 72 | + { |
|
| 73 | + if ($this->isVerbose()) |
|
| 74 | + { |
|
| 67 | 75 | $this->sprintf( |
| 68 | 76 | "<fg=red>•</fg=red> %s: <fg=red>%s at line %s</fg=red>", |
| 69 | 77 | $path, |
@@ -72,8 +80,11 @@ discard block |
||
| 72 | 80 | ); |
| 73 | 81 | } |
| 74 | 82 | continue; |
| 75 | - } finally { |
|
| 76 | - if ($this->isVerbose()) { |
|
| 83 | + } |
|
| 84 | + finally |
|
| 85 | + { |
|
| 86 | + if ($this->isVerbose()) |
|
| 87 | + { |
|
| 77 | 88 | $this->sprintf( |
| 78 | 89 | " %s[%s ms]%s\n", |
| 79 | 90 | Color::GRAY, |
@@ -84,8 +95,10 @@ discard block |
||
| 84 | 95 | } |
| 85 | 96 | } |
| 86 | 97 | |
| 87 | - if ($this->isVerbose()) { |
|
| 88 | - if (empty($path)) { |
|
| 98 | + if ($this->isVerbose()) |
|
| 99 | + { |
|
| 100 | + if (empty($path)) |
|
| 101 | + { |
|
| 89 | 102 | $this->writeln("• no views found"); |
| 90 | 103 | } |
| 91 | 104 | |
@@ -101,7 +114,8 @@ discard block |
||
| 101 | 114 | { |
| 102 | 115 | $values = []; |
| 103 | 116 | |
| 104 | - foreach ($context->getDependencies() as $dependency) { |
|
| 117 | + foreach ($context->getDependencies() as $dependency) |
|
| 118 | + { |
|
| 105 | 119 | $values[] = sprintf( |
| 106 | 120 | "%s%s%s:%s%s%s", |
| 107 | 121 | Color::LIGHT_WHITE, |
@@ -43,18 +43,18 @@ discard block |
||
| 43 | 43 | string $destination, |
| 44 | 44 | string $mergeMode = self::FOLLOW, |
| 45 | 45 | int $mode = FilesInterface::READONLY |
| 46 | - ) { |
|
| 47 | - if (!$this->files->isFile($filename)) { |
|
| 46 | + ){ |
|
| 47 | + if (!$this->files->isFile($filename)){ |
|
| 48 | 48 | throw new PublishException("Given '{$filename}' is not valid file"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if ($this->files->exists($destination)) { |
|
| 52 | - if ($this->files->md5($destination) == $this->files->md5($filename)) { |
|
| 51 | + if ($this->files->exists($destination)){ |
|
| 52 | + if ($this->files->md5($destination) == $this->files->md5($filename)){ |
|
| 53 | 53 | //Nothing to do |
| 54 | 54 | return; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if ($mergeMode == self::FOLLOW) { |
|
| 57 | + if ($mergeMode == self::FOLLOW){ |
|
| 58 | 58 | return; |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | string $destination, |
| 76 | 76 | string $mergeMode = self::REPLACE, |
| 77 | 77 | int $mode = FilesInterface::READONLY |
| 78 | - ) { |
|
| 79 | - if (!$this->files->isDirectory($directory)) { |
|
| 78 | + ){ |
|
| 79 | + if (!$this->files->isDirectory($directory)){ |
|
| 80 | 80 | throw new PublishException("Given '{$directory}' is not valid directory"); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | /** |
| 87 | 87 | * @var SplFileInfo $file |
| 88 | 88 | */ |
| 89 | - foreach ($finder->getIterator() as $file) { |
|
| 89 | + foreach ($finder->getIterator() as $file){ |
|
| 90 | 90 | $this->publish( |
| 91 | 91 | (string)$file, |
| 92 | - $destination . '/' . $file->getRelativePathname(), |
|
| 92 | + $destination.'/'.$file->getRelativePathname(), |
|
| 93 | 93 | $mergeMode, |
| 94 | 94 | $mode |
| 95 | 95 | ); |
@@ -44,17 +44,21 @@ discard block |
||
| 44 | 44 | string $mergeMode = self::FOLLOW, |
| 45 | 45 | int $mode = FilesInterface::READONLY |
| 46 | 46 | ) { |
| 47 | - if (!$this->files->isFile($filename)) { |
|
| 47 | + if (!$this->files->isFile($filename)) |
|
| 48 | + { |
|
| 48 | 49 | throw new PublishException("Given '{$filename}' is not valid file"); |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | - if ($this->files->exists($destination)) { |
|
| 52 | - if ($this->files->md5($destination) == $this->files->md5($filename)) { |
|
| 52 | + if ($this->files->exists($destination)) |
|
| 53 | + { |
|
| 54 | + if ($this->files->md5($destination) == $this->files->md5($filename)) |
|
| 55 | + { |
|
| 53 | 56 | //Nothing to do |
| 54 | 57 | return; |
| 55 | 58 | } |
| 56 | 59 | |
| 57 | - if ($mergeMode == self::FOLLOW) { |
|
| 60 | + if ($mergeMode == self::FOLLOW) |
|
| 61 | + { |
|
| 58 | 62 | return; |
| 59 | 63 | } |
| 60 | 64 | } |
@@ -76,7 +80,8 @@ discard block |
||
| 76 | 80 | string $mergeMode = self::REPLACE, |
| 77 | 81 | int $mode = FilesInterface::READONLY |
| 78 | 82 | ) { |
| 79 | - if (!$this->files->isDirectory($directory)) { |
|
| 83 | + if (!$this->files->isDirectory($directory)) |
|
| 84 | + { |
|
| 80 | 85 | throw new PublishException("Given '{$directory}' is not valid directory"); |
| 81 | 86 | } |
| 82 | 87 | |
@@ -86,7 +91,8 @@ discard block |
||
| 86 | 91 | /** |
| 87 | 92 | * @var SplFileInfo $file |
| 88 | 93 | */ |
| 89 | - foreach ($finder->getIterator() as $file) { |
|
| 94 | + foreach ($finder->getIterator() as $file) |
|
| 95 | + { |
|
| 90 | 96 | $this->publish( |
| 91 | 97 | (string)$file, |
| 92 | 98 | $destination . '/' . $file->getRelativePathname(), |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function getValue(string $source, string $name = null) |
| 43 | 43 | { |
| 44 | - if (!method_exists($this->input, $source)) { |
|
| 44 | + if (!method_exists($this->input, $source)){ |
|
| 45 | 45 | throw new InputException("Undefined input source '{$source}'"); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -41,7 +41,8 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function getValue(string $source, string $name = null) |
| 43 | 43 | { |
| 44 | - if (!method_exists($this->input, $source)) { |
|
| 44 | + if (!method_exists($this->input, $source)) |
|
| 45 | + { |
|
| 45 | 46 | throw new InputException("Undefined input source '{$source}'"); |
| 46 | 47 | } |
| 47 | 48 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
| 45 | 45 | { |
| 46 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
| 46 | + if (!$this->container->has(ServerRequestInterface::class)){ |
|
| 47 | 47 | throw new ScopeException("Unable to create paginator, no request scope found"); |
| 48 | 48 | } |
| 49 | 49 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | //Getting page number |
| 55 | 55 | $page = 0; |
| 56 | - if (!empty($query[$parameter]) && is_scalar($query[$parameter])) { |
|
| 56 | + if (!empty($query[$parameter]) && is_scalar($query[$parameter])){ |
|
| 57 | 57 | $page = (int)$query[$parameter]; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -43,7 +43,8 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
| 45 | 45 | { |
| 46 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
| 46 | + if (!$this->container->has(ServerRequestInterface::class)) |
|
| 47 | + { |
|
| 47 | 48 | throw new ScopeException("Unable to create paginator, no request scope found"); |
| 48 | 49 | } |
| 49 | 50 | /** |
@@ -53,7 +54,8 @@ discard block |
||
| 53 | 54 | |
| 54 | 55 | //Getting page number |
| 55 | 56 | $page = 0; |
| 56 | - if (!empty($query[$parameter]) && is_scalar($query[$parameter])) { |
|
| 57 | + if (!empty($query[$parameter]) && is_scalar($query[$parameter])) |
|
| 58 | + { |
|
| 57 | 59 | $page = (int)$query[$parameter]; |
| 58 | 60 | } |
| 59 | 61 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | RendererInterface $renderer, |
| 44 | 44 | bool $suppressErrors = true, |
| 45 | 45 | SnapshotterInterface $snapshotter = null |
| 46 | - ) { |
|
| 46 | + ){ |
|
| 47 | 47 | $this->renderer = $renderer; |
| 48 | 48 | $this->suppressErrors = $suppressErrors; |
| 49 | 49 | $this->snapshotter = $snapshotter; |
@@ -54,20 +54,20 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function process(Request $request, Handler $handler): Response |
| 56 | 56 | { |
| 57 | - try { |
|
| 57 | + try{ |
|
| 58 | 58 | return $handler->handle($request); |
| 59 | - } catch (ClientException|RouteNotFoundException $e) { |
|
| 60 | - if ($e instanceof ClientException) { |
|
| 59 | + }catch (ClientException | RouteNotFoundException $e){ |
|
| 60 | + if ($e instanceof ClientException){ |
|
| 61 | 61 | $code = $e->getCode(); |
| 62 | - } else { |
|
| 62 | + }else{ |
|
| 63 | 63 | $code = 404; |
| 64 | 64 | } |
| 65 | - } catch (\Throwable $e) { |
|
| 66 | - if (!$this->suppressErrors) { |
|
| 65 | + }catch (\Throwable $e){ |
|
| 66 | + if (!$this->suppressErrors){ |
|
| 67 | 67 | throw $e; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if (!empty($this->snapshotter)) { |
|
| 70 | + if (!empty($this->snapshotter)){ |
|
| 71 | 71 | $this->snapshotter->register($e); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -54,20 +54,30 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | public function process(Request $request, Handler $handler): Response |
| 56 | 56 | { |
| 57 | - try { |
|
| 57 | + try |
|
| 58 | + { |
|
| 58 | 59 | return $handler->handle($request); |
| 59 | - } catch (ClientException|RouteNotFoundException $e) { |
|
| 60 | - if ($e instanceof ClientException) { |
|
| 60 | + } |
|
| 61 | + catch (ClientException|RouteNotFoundException $e) |
|
| 62 | + { |
|
| 63 | + if ($e instanceof ClientException) |
|
| 64 | + { |
|
| 61 | 65 | $code = $e->getCode(); |
| 62 | - } else { |
|
| 66 | + } |
|
| 67 | + else |
|
| 68 | + { |
|
| 63 | 69 | $code = 404; |
| 64 | 70 | } |
| 65 | - } catch (\Throwable $e) { |
|
| 66 | - if (!$this->suppressErrors) { |
|
| 71 | + } |
|
| 72 | + catch (\Throwable $e) |
|
| 73 | + { |
|
| 74 | + if (!$this->suppressErrors) |
|
| 75 | + { |
|
| 67 | 76 | throw $e; |
| 68 | 77 | } |
| 69 | 78 | |
| 70 | - if (!empty($this->snapshotter)) { |
|
| 79 | + if (!empty($this->snapshotter)) |
|
| 80 | + { |
|
| 71 | 81 | $this->snapshotter->register($e); |
| 72 | 82 | } |
| 73 | 83 | |
@@ -46,7 +46,8 @@ |
||
| 46 | 46 | //We are not forcing locale for now |
| 47 | 47 | return $source->withCode(preg_replace_callback( |
| 48 | 48 | self::REGEXP, |
| 49 | - function ($matches) use ($domain, $context) { |
|
| 49 | + function ($matches) use ($domain, $context) |
|
| 50 | + { |
|
| 50 | 51 | return $this->translator->trans( |
| 51 | 52 | $matches[1], |
| 52 | 53 | [], |