@@ -128,7 +128,7 @@ |
||
| 128 | 128 | private function getFileMode(): int |
| 129 | 129 | { |
| 130 | 130 | return match ($this->argument('mode')) { |
| 131 | - 'readonly' => FilesInterface::READONLY, |
|
| 131 | + 'readonly' => FilesInterface::readonly, |
|
| 132 | 132 | 'runtime' => FilesInterface::RUNTIME, |
| 133 | 133 | default => FilesInterface::RUNTIME, |
| 134 | 134 | }; |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | FilesInterface $files, |
| 47 | 47 | DirectoriesInterface $directories, |
| 48 | 48 | ): int { |
| 49 | - switch ($this->argument('type')) { |
|
| 49 | + switch ($this->argument('type')){ |
|
| 50 | 50 | case 'replace': |
| 51 | 51 | case 'follow': |
| 52 | - if ($this->isDirectory()) { |
|
| 52 | + if ($this->isDirectory()){ |
|
| 53 | 53 | $this->sprintf( |
| 54 | 54 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
| 55 | 55 | $this->getSource($files), |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $this->getMergeMode(), |
| 63 | 63 | $this->getFileMode(), |
| 64 | 64 | ); |
| 65 | - } else { |
|
| 65 | + }else{ |
|
| 66 | 66 | $this->sprintf( |
| 67 | 67 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
| 68 | 68 | $this->getSource($files), |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | private function getSource(FilesInterface $files): ?string |
| 101 | 101 | { |
| 102 | - if (!$this->isDirectory()) { |
|
| 102 | + if (!$this->isDirectory()){ |
|
| 103 | 103 | return $files->normalizePath($this->argument('source')); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
| 110 | 110 | { |
| 111 | 111 | $target = $this->argument('target'); |
| 112 | - foreach ($directories->getAll() as $alias => $value) { |
|
| 112 | + foreach ($directories->getAll() as $alias => $value){ |
|
| 113 | 113 | $target = \str_replace(\sprintf('@%s', $alias), $value, $target); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | return match (true) { |
| 122 | 122 | $this->argument('type') === 'ensure' => true, |
| 123 | - \str_contains((string) $this->argument('source'), '*') => true, |
|
| 123 | + \str_contains((string)$this->argument('source'), '*') => true, |
|
| 124 | 124 | default => \is_dir($this->argument('source')), |
| 125 | 125 | }; |
| 126 | 126 | } |
@@ -46,10 +46,12 @@ discard block |
||
| 46 | 46 | FilesInterface $files, |
| 47 | 47 | DirectoriesInterface $directories, |
| 48 | 48 | ): int { |
| 49 | - switch ($this->argument('type')) { |
|
| 49 | + switch ($this->argument('type')) |
|
| 50 | + { |
|
| 50 | 51 | case 'replace': |
| 51 | 52 | case 'follow': |
| 52 | - if ($this->isDirectory()) { |
|
| 53 | + if ($this->isDirectory()) |
|
| 54 | + { |
|
| 53 | 55 | $this->sprintf( |
| 54 | 56 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
| 55 | 57 | $this->getSource($files), |
@@ -62,7 +64,9 @@ discard block |
||
| 62 | 64 | $this->getMergeMode(), |
| 63 | 65 | $this->getFileMode(), |
| 64 | 66 | ); |
| 65 | - } else { |
|
| 67 | + } |
|
| 68 | + else |
|
| 69 | + { |
|
| 66 | 70 | $this->sprintf( |
| 67 | 71 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
| 68 | 72 | $this->getSource($files), |
@@ -99,7 +103,8 @@ discard block |
||
| 99 | 103 | |
| 100 | 104 | private function getSource(FilesInterface $files): ?string |
| 101 | 105 | { |
| 102 | - if (!$this->isDirectory()) { |
|
| 106 | + if (!$this->isDirectory()) |
|
| 107 | + { |
|
| 103 | 108 | return $files->normalizePath($this->argument('source')); |
| 104 | 109 | } |
| 105 | 110 | |
@@ -109,7 +114,8 @@ discard block |
||
| 109 | 114 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
| 110 | 115 | { |
| 111 | 116 | $target = $this->argument('target'); |
| 112 | - foreach ($directories->getAll() as $alias => $value) { |
|
| 117 | + foreach ($directories->getAll() as $alias => $value) |
|
| 118 | + { |
|
| 113 | 119 | $target = \str_replace(\sprintf('@%s', $alias), $value, $target); |
| 114 | 120 | } |
| 115 | 121 | |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | $this->sprintf("<info>New encryption key:</info> <fg=cyan>%s</fg=cyan>\n", $key); |
| 41 | 41 | |
| 42 | 42 | $file = $this->option('mount'); |
| 43 | - if ($file === null) { |
|
| 43 | + if ($file === null){ |
|
| 44 | 44 | return self::SUCCESS; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (!$confirmation->confirmToProceed()) { |
|
| 47 | + if (!$confirmation->confirmToProceed()){ |
|
| 48 | 48 | return self::FAILURE; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if (!$files->exists($file)) { |
|
| 51 | + if (!$files->exists($file)){ |
|
| 52 | 52 | $this->error(\sprintf('Unable to find `%s`.', $file)); |
| 53 | 53 | |
| 54 | 54 | return self::FAILURE; |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $content = $files->read($file); |
| 58 | 58 | |
| 59 | - try { |
|
| 59 | + try{ |
|
| 60 | 60 | $content = \str_replace($this->option('placeholder'), $key, $content); |
| 61 | 61 | $content = \str_replace($enc->getKey(), $key, $content); |
| 62 | - } catch (\Throwable) { |
|
| 62 | + }catch (\Throwable){ |
|
| 63 | 63 | // current keys is not set |
| 64 | 64 | } |
| 65 | 65 | |
@@ -40,15 +40,18 @@ discard block |
||
| 40 | 40 | $this->sprintf("<info>New encryption key:</info> <fg=cyan>%s</fg=cyan>\n", $key); |
| 41 | 41 | |
| 42 | 42 | $file = $this->option('mount'); |
| 43 | - if ($file === null) { |
|
| 43 | + if ($file === null) |
|
| 44 | + { |
|
| 44 | 45 | return self::SUCCESS; |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | - if (!$confirmation->confirmToProceed()) { |
|
| 48 | + if (!$confirmation->confirmToProceed()) |
|
| 49 | + { |
|
| 48 | 50 | return self::FAILURE; |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | - if (!$files->exists($file)) { |
|
| 53 | + if (!$files->exists($file)) |
|
| 54 | + { |
|
| 52 | 55 | $this->error(\sprintf('Unable to find `%s`.', $file)); |
| 53 | 56 | |
| 54 | 57 | return self::FAILURE; |
@@ -56,10 +59,13 @@ discard block |
||
| 56 | 59 | |
| 57 | 60 | $content = $files->read($file); |
| 58 | 61 | |
| 59 | - try { |
|
| 62 | + try |
|
| 63 | + { |
|
| 60 | 64 | $content = \str_replace($this->option('placeholder'), $key, $content); |
| 61 | 65 | $content = \str_replace($enc->getKey(), $key, $content); |
| 62 | - } catch (\Throwable) { |
|
| 66 | + } |
|
| 67 | + catch (\Throwable) |
|
| 68 | + { |
|
| 63 | 69 | // current keys is not set |
| 64 | 70 | } |
| 65 | 71 | |
@@ -36,7 +36,8 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function appBooting(\Closure ...$callbacks): void |
| 38 | 38 | { |
| 39 | - foreach ($callbacks as $callback) { |
|
| 39 | + foreach ($callbacks as $callback) |
|
| 40 | + { |
|
| 40 | 41 | $this->bootingCallbacks[] = $callback; |
| 41 | 42 | } |
| 42 | 43 | } |
@@ -51,7 +52,8 @@ discard block |
||
| 51 | 52 | */ |
| 52 | 53 | public function appBooted(\Closure ...$callbacks): void |
| 53 | 54 | { |
| 54 | - foreach ($callbacks as $callback) { |
|
| 55 | + foreach ($callbacks as $callback) |
|
| 56 | + { |
|
| 55 | 57 | $this->bootedCallbacks[] = $callback; |
| 56 | 58 | } |
| 57 | 59 | } |
@@ -89,11 +91,13 @@ discard block |
||
| 89 | 91 | */ |
| 90 | 92 | protected function mapDirectories(array $directories): array |
| 91 | 93 | { |
| 92 | - if (!isset($directories['root'])) { |
|
| 94 | + if (!isset($directories['root'])) |
|
| 95 | + { |
|
| 93 | 96 | throw new BootException('Missing required directory `root`'); |
| 94 | 97 | } |
| 95 | 98 | |
| 96 | - if (!isset($directories['app'])) { |
|
| 99 | + if (!isset($directories['app'])) |
|
| 100 | + { |
|
| 97 | 101 | $directories['app'] = $directories['root'] . '/app/'; |
| 98 | 102 | } |
| 99 | 103 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function appBooting(\Closure ...$callbacks): void |
| 46 | 46 | { |
| 47 | - foreach ($callbacks as $callback) { |
|
| 47 | + foreach ($callbacks as $callback){ |
|
| 48 | 48 | $this->bootingCallbacks[] = $callback; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function appBooted(\Closure ...$callbacks): void |
| 61 | 61 | { |
| 62 | - foreach ($callbacks as $callback) { |
|
| 62 | + foreach ($callbacks as $callback){ |
|
| 63 | 63 | $this->bootedCallbacks[] = $callback; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -99,29 +99,29 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function mapDirectories(array $directories): array |
| 101 | 101 | { |
| 102 | - if (!isset($directories['root'])) { |
|
| 102 | + if (!isset($directories['root'])){ |
|
| 103 | 103 | throw new BootException('Missing required directory `root`'); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if (!isset($directories['app'])) { |
|
| 107 | - $directories['app'] = $directories['root'] . '/app/'; |
|
| 106 | + if (!isset($directories['app'])){ |
|
| 107 | + $directories['app'] = $directories['root'].'/app/'; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | return \array_merge( |
| 111 | 111 | [ |
| 112 | 112 | // public root |
| 113 | - 'public' => $directories['root'] . '/public/', |
|
| 113 | + 'public' => $directories['root'].'/public/', |
|
| 114 | 114 | |
| 115 | 115 | // vendor libraries |
| 116 | - 'vendor' => $directories['root'] . '/vendor/', |
|
| 116 | + 'vendor' => $directories['root'].'/vendor/', |
|
| 117 | 117 | |
| 118 | 118 | // data directories |
| 119 | - 'runtime' => $directories['root'] . '/runtime/', |
|
| 120 | - 'cache' => $directories['root'] . '/runtime/cache/', |
|
| 119 | + 'runtime' => $directories['root'].'/runtime/', |
|
| 120 | + 'cache' => $directories['root'].'/runtime/cache/', |
|
| 121 | 121 | |
| 122 | 122 | // application directories |
| 123 | - 'config' => $directories['app'] . '/config/', |
|
| 124 | - 'resources' => $directories['app'] . '/resources/', |
|
| 123 | + 'config' => $directories['app'].'/config/', |
|
| 124 | + 'resources' => $directories['app'].'/resources/', |
|
| 125 | 125 | ], |
| 126 | 126 | $directories, |
| 127 | 127 | ); |
@@ -23,11 +23,11 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null) |
| 25 | 25 | { |
| 26 | - if (empty($code) && empty($this->code)) { |
|
| 26 | + if (empty($code) && empty($this->code)){ |
|
| 27 | 27 | $code = self::BAD_DATA; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if (empty($message)) { |
|
| 30 | + if (empty($message)){ |
|
| 31 | 31 | $message = \sprintf('Http Error - %s', $code); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -23,11 +23,13 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null) |
| 25 | 25 | { |
| 26 | - if (empty($code) && empty($this->code)) { |
|
| 26 | + if (empty($code) && empty($this->code)) |
|
| 27 | + { |
|
| 27 | 28 | $code = self::BAD_DATA; |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | - if (empty($message)) { |
|
| 31 | + if (empty($message)) |
|
| 32 | + { |
|
| 31 | 33 | $message = \sprintf('Http Error - %s', $code); |
| 32 | 34 | } |
| 33 | 35 | |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface |
| 18 | 18 | { |
| 19 | - if ($payload instanceof \JsonSerializable) { |
|
| 19 | + if ($payload instanceof \JsonSerializable){ |
|
| 20 | 20 | $payload = $payload->jsonSerialize(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) { |
|
| 23 | + if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])){ |
|
| 24 | 24 | $code = $payload['status']; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -16,11 +16,13 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface |
| 18 | 18 | { |
| 19 | - if ($payload instanceof \JsonSerializable) { |
|
| 19 | + if ($payload instanceof \JsonSerializable) |
|
| 20 | + { |
|
| 20 | 21 | $payload = $payload->jsonSerialize(); |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | - if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) { |
|
| 24 | + if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) |
|
| 25 | + { |
|
| 24 | 26 | $code = $payload['status']; |
| 25 | 27 | } |
| 26 | 28 | |
@@ -10,14 +10,14 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | final class ServerBag extends InputBag |
| 12 | 12 | { |
| 13 | - public function has(int|string $name): bool |
|
| 13 | + public function has(int | string $name): bool |
|
| 14 | 14 | { |
| 15 | - return parent::has($this->normalize((string) $name)); |
|
| 15 | + return parent::has($this->normalize((string)$name)); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function get(int|string $name, mixed $default = null): mixed |
|
| 18 | + public function get(int | string $name, mixed $default = null): mixed |
|
| 19 | 19 | { |
| 20 | - return parent::get($this->normalize((string) $name), $default); |
|
| 20 | + return parent::get($this->normalize((string)$name), $default); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function fetch(array $keys, bool $fill = false, mixed $filler = null): array |
@@ -20,9 +20,9 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * Locale local filename (virtual filename) associated with UploadedFile resource. |
| 22 | 22 | */ |
| 23 | - public function getFilename(int|string $name): ?string |
|
| 23 | + public function getFilename(int | string $name): ?string |
|
| 24 | 24 | { |
| 25 | - if (!empty($file = $this->get($name)) && !$file->getError()) { |
|
| 25 | + if (!empty($file = $this->get($name)) && !$file->getError()){ |
|
| 26 | 26 | return StreamWrapper::getFilename($file->getStream()); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -22,7 +22,8 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function getFilename(int|string $name): ?string |
| 24 | 24 | { |
| 25 | - if (!empty($file = $this->get($name)) && !$file->getError()) { |
|
| 25 | + if (!empty($file = $this->get($name)) && !$file->getError()) |
|
| 26 | + { |
|
| 26 | 27 | return StreamWrapper::getFilename($file->getStream()); |
| 27 | 28 | } |
| 28 | 29 | |
@@ -22,7 +22,8 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $value = parent::get($this->normalize((string) $name), $default); |
| 24 | 24 | |
| 25 | - if (\is_string($implode) && !empty($implode) && \is_array($value)) { |
|
| 25 | + if (\is_string($implode) && !empty($implode) && \is_array($value)) |
|
| 26 | + { |
|
| 26 | 27 | return \implode($implode, $value); |
| 27 | 28 | } |
| 28 | 29 | |
@@ -38,8 +39,10 @@ discard block |
||
| 38 | 39 | |
| 39 | 40 | $values = parent::fetch($keys, $fill, $filler); |
| 40 | 41 | |
| 41 | - if (!empty($implode)) { |
|
| 42 | - foreach ($values as &$value) { |
|
| 42 | + if (!empty($implode)) |
|
| 43 | + { |
|
| 44 | + foreach ($values as &$value) |
|
| 45 | + { |
|
| 43 | 46 | $value = \implode($implode, $value); |
| 44 | 47 | unset($value); |
| 45 | 48 | } |
@@ -10,19 +10,19 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | final class HeadersBag extends InputBag |
| 12 | 12 | { |
| 13 | - public function has(int|string $name): bool |
|
| 13 | + public function has(int | string $name): bool |
|
| 14 | 14 | { |
| 15 | - return parent::has($this->normalize((string) $name)); |
|
| 15 | + return parent::has($this->normalize((string)$name)); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @param false|string $implode Implode header lines, false to return header as array. |
| 20 | 20 | */ |
| 21 | - public function get(int|string $name, mixed $default = null, bool|string $implode = ','): array|string|null |
|
| 21 | + public function get(int | string $name, mixed $default = null, bool | string $implode = ','): array | string | null |
|
| 22 | 22 | { |
| 23 | - $value = parent::get($this->normalize((string) $name), $default); |
|
| 23 | + $value = parent::get($this->normalize((string)$name), $default); |
|
| 24 | 24 | |
| 25 | - if (\is_string($implode) && !empty($implode) && \is_array($value)) { |
|
| 25 | + if (\is_string($implode) && !empty($implode) && \is_array($value)){ |
|
| 26 | 26 | return \implode($implode, $value); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function fetch(array $keys, bool $fill = false, mixed $filler = null, ?string $implode = ','): array |
| 36 | 36 | { |
| 37 | - $keys = \array_map(fn(string $header): string => $this->normalize($header), $keys); |
|
| 37 | + $keys = \array_map(fn(string $header) : string => $this->normalize($header), $keys); |
|
| 38 | 38 | |
| 39 | 39 | $values = parent::fetch($keys, $fill, $filler); |
| 40 | 40 | |
| 41 | - if (!empty($implode)) { |
|
| 42 | - foreach ($values as &$value) { |
|
| 41 | + if (!empty($implode)){ |
|
| 42 | + foreach ($values as &$value){ |
|
| 43 | 43 | $value = \implode($implode, $value); |
| 44 | 44 | unset($value); |
| 45 | 45 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | public function init(ViewsBootloader $views): void |
| 27 | 27 | { |
| 28 | - $views->addDirectory('sendit', __DIR__ . '/../../views'); |
|
| 28 | + $views->addDirectory('sendit', __DIR__.'/../../views'); |
|
| 29 | 29 | } |
| 30 | 30 | } |