@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * @class TextPlainErrorRenderer |
55 | 55 | * @package Platine\Framework\Handler\Error\Renderer |
56 | 56 | */ |
57 | -class TextPlainErrorRenderer extends AbstractErrorRenderer |
|
58 | -{ |
|
57 | +class TextPlainErrorRenderer extends AbstractErrorRenderer { |
|
59 | 58 | /** |
60 | 59 | * {@inheritdoc} |
61 | 60 | */ |
@@ -63,13 +62,13 @@ discard block |
||
63 | 62 | { |
64 | 63 | $error = $this->getErrorTitle($exception) . "\n"; |
65 | 64 | |
66 | - if ($isLog) { |
|
65 | + if ($isLog) { |
|
67 | 66 | return $error; |
68 | 67 | } |
69 | 68 | |
70 | - if ($detail) { |
|
69 | + if ($detail) { |
|
71 | 70 | $error .= $this->getExceptionText($exception); |
72 | - while ($exception = $exception->getPrevious()) { |
|
71 | + while ($exception = $exception->getPrevious()) { |
|
73 | 72 | $error .= "\nPrevious Error:\n"; |
74 | 73 | $error .= $this->getExceptionText($exception); |
75 | 74 | } |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | * @class JsonErrorRenderer |
56 | 56 | * @package Platine\Framework\Handler\Error\Renderer |
57 | 57 | */ |
58 | -class JsonErrorRenderer extends AbstractErrorRenderer |
|
59 | -{ |
|
58 | +class JsonErrorRenderer extends AbstractErrorRenderer { |
|
60 | 59 | /** |
61 | 60 | * {@inheritdoc} |
62 | 61 | */ |
@@ -67,9 +66,9 @@ discard block |
||
67 | 66 | 'message' => $this->getErrorDescription($exception), |
68 | 67 | ]; |
69 | 68 | |
70 | - if ($detail) { |
|
69 | + if ($detail) { |
|
71 | 70 | $error['exception'] = []; |
72 | - do { |
|
71 | + do { |
|
73 | 72 | $error['exception'][] = $this->getExceptionData($exception); |
74 | 73 | } while ($exception = $exception->getPrevious()); |
75 | 74 | } |
@@ -56,8 +56,7 @@ |
||
56 | 56 | * @class ErrorHandlerInterface |
57 | 57 | * @package Platine\Framework\Handler\Error |
58 | 58 | */ |
59 | -interface ErrorHandlerInterface |
|
60 | -{ |
|
59 | +interface ErrorHandlerInterface { |
|
61 | 60 | /** |
62 | 61 | * Handle error and generate the response |
63 | 62 | * @param ServerRequestInterface $request |
@@ -54,8 +54,7 @@ |
||
54 | 54 | * @class ErrorRenderInterface |
55 | 55 | * @package Platine\Framework\Handler\Error |
56 | 56 | */ |
57 | -interface ErrorRenderInterface |
|
58 | -{ |
|
57 | +interface ErrorRenderInterface { |
|
59 | 58 | /** |
60 | 59 | * Render the error |
61 | 60 | * @param Throwable $exception |
@@ -63,8 +63,7 @@ discard block |
||
63 | 63 | * @class ErrorHandler |
64 | 64 | * @package Platine\Framework\Handler\Error |
65 | 65 | */ |
66 | -class ErrorHandler implements ErrorHandlerInterface |
|
67 | -{ |
|
66 | +class ErrorHandler implements ErrorHandlerInterface { |
|
68 | 67 | /** |
69 | 68 | * The content type |
70 | 69 | * @var string |
@@ -123,8 +122,7 @@ discard block |
||
123 | 122 | * Create new instance |
124 | 123 | * @param LoggerInterface $logger |
125 | 124 | */ |
126 | - public function __construct(LoggerInterface $logger) |
|
127 | - { |
|
125 | + public function __construct(LoggerInterface $logger) { |
|
128 | 126 | $this->logger = $logger; |
129 | 127 | |
130 | 128 | //Add default renderer |
@@ -148,7 +146,7 @@ discard block |
||
148 | 146 | $this->exception = $exception; |
149 | 147 | $this->method = $request->getMethod(); |
150 | 148 | $this->statusCode = $this->determineStatusCode(); |
151 | - if (empty($this->contentType)) { |
|
149 | + if (empty($this->contentType)) { |
|
152 | 150 | $this->contentType = $this->getRequestContentType($request); |
153 | 151 | } |
154 | 152 | |
@@ -206,11 +204,11 @@ discard block |
||
206 | 204 | */ |
207 | 205 | protected function determineStatusCode(): int |
208 | 206 | { |
209 | - if ($this->method === 'OPTIONS') { |
|
207 | + if ($this->method === 'OPTIONS') { |
|
210 | 208 | return 200; |
211 | 209 | } |
212 | 210 | |
213 | - if ($this->exception instanceof HttpException) { |
|
211 | + if ($this->exception instanceof HttpException) { |
|
214 | 212 | return $this->exception->getCode(); |
215 | 213 | } |
216 | 214 | |
@@ -226,9 +224,9 @@ discard block |
||
226 | 224 | if ( |
227 | 225 | !empty($this->contentType) |
228 | 226 | && array_key_exists($this->contentType, $this->renderers) |
229 | - ) { |
|
227 | + ) { |
|
230 | 228 | $renderer = $this->renderers[$this->contentType]; |
231 | - } else { |
|
229 | + } else { |
|
232 | 230 | $renderer = $this->renderer; |
233 | 231 | } |
234 | 232 | |
@@ -250,29 +248,29 @@ discard block |
||
250 | 248 | |
251 | 249 | $count = count($selected); |
252 | 250 | |
253 | - if ($count > 0) { |
|
251 | + if ($count > 0) { |
|
254 | 252 | $current = current($selected); |
255 | 253 | |
256 | 254 | /** |
257 | 255 | * Ensure other supported content types take precedence over text/plain |
258 | 256 | * when multiple content types are provided via Accept header. |
259 | 257 | */ |
260 | - if ($current === 'text/plain' && $count > 1) { |
|
258 | + if ($current === 'text/plain' && $count > 1) { |
|
261 | 259 | $next = next($selected); |
262 | - if (is_string($next)) { |
|
260 | + if (is_string($next)) { |
|
263 | 261 | return $next; |
264 | 262 | } |
265 | 263 | } |
266 | 264 | |
267 | - if (is_string($current)) { |
|
265 | + if (is_string($current)) { |
|
268 | 266 | return $current; |
269 | 267 | } |
270 | 268 | } |
271 | 269 | |
272 | 270 | $matches = []; |
273 | - if (preg_match('/\+(json|xml)/', $header, $matches)) { |
|
271 | + if (preg_match('/\+(json|xml)/', $header, $matches)) { |
|
274 | 272 | $contentType = 'application/' . $matches[1]; |
275 | - if (array_key_exists($contentType, $this->renderers)) { |
|
273 | + if (array_key_exists($contentType, $this->renderers)) { |
|
276 | 274 | return $contentType; |
277 | 275 | } |
278 | 276 | } |
@@ -312,18 +310,18 @@ discard block |
||
312 | 310 | if ( |
313 | 311 | !empty($this->contentType) |
314 | 312 | && array_key_exists($this->contentType, $this->renderers) |
315 | - ) { |
|
313 | + ) { |
|
316 | 314 | $response = $response->withHeader('Content-Type', $this->contentType); |
317 | 315 | } |
318 | 316 | |
319 | - if ($this->exception instanceof HttpMethodNotAllowedException) { |
|
317 | + if ($this->exception instanceof HttpMethodNotAllowedException) { |
|
320 | 318 | $allowMethods = implode(', ', $this->exception->getAllowedMethods()); |
321 | 319 | $response = $response->withHeader('Allow', $allowMethods); |
322 | 320 | } |
323 | 321 | |
324 | - if ($this->exception instanceof HttpException) { |
|
322 | + if ($this->exception instanceof HttpException) { |
|
325 | 323 | $headers = $this->exception->getHeaders(); |
326 | - foreach ($headers as $name => $value) { |
|
324 | + foreach ($headers as $name => $value) { |
|
327 | 325 | $response = $response->withAddedHeader($name, $value); |
328 | 326 | } |
329 | 327 | } |
@@ -56,8 +56,7 @@ |
||
56 | 56 | * @package Platine\Framework\Migration |
57 | 57 | * @extends Entity<MigrationEntity> |
58 | 58 | */ |
59 | -class MigrationEntity extends Entity |
|
60 | -{ |
|
59 | +class MigrationEntity extends Entity { |
|
61 | 60 | /** |
62 | 61 | * |
63 | 62 | * @param EntityMapperInterface<MigrationEntity> $mapper |
@@ -70,7 +70,7 @@ |
||
70 | 70 | ) { |
71 | 71 | parent::__construct($app, $config, $filesystem); |
72 | 72 | $this->setName('seed:status') |
73 | - ->setDescription('Show your database seeds status'); |
|
73 | + ->setDescription('Show your database seeds status'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * @template T |
58 | 58 | * @extends AbstractSeedCommand<T> |
59 | 59 | */ |
60 | -class SeedStatusCommand extends AbstractSeedCommand |
|
61 | -{ |
|
60 | +class SeedStatusCommand extends AbstractSeedCommand { |
|
62 | 61 | /** |
63 | 62 | * Create new instance |
64 | 63 | * {@inheritdoc} |
@@ -67,7 +66,7 @@ discard block |
||
67 | 66 | Application $app, |
68 | 67 | Config $config, |
69 | 68 | Filesystem $filesystem |
70 | - ) { |
|
69 | + ) { |
|
71 | 70 | parent::__construct($app, $config, $filesystem); |
72 | 71 | $this->setName('seed:status') |
73 | 72 | ->setDescription('Show your database seeds status'); |
@@ -76,8 +75,7 @@ discard block |
||
76 | 75 | /** |
77 | 76 | * {@inheritdoc} |
78 | 77 | */ |
79 | - public function execute() |
|
80 | - { |
|
78 | + public function execute() { |
|
81 | 79 | $writer = $this->io()->writer(); |
82 | 80 | $writer->boldYellow('SEED STATUS', true)->eol(); |
83 | 81 | $writer->bold('Seed path: '); |
@@ -90,7 +88,7 @@ discard block |
||
90 | 88 | |
91 | 89 | $rows = []; |
92 | 90 | $index = 1; |
93 | - foreach ($seeds as $description) { |
|
91 | + foreach ($seeds as $description) { |
|
94 | 92 | $rows[] = [ |
95 | 93 | 'No.' => (string) $index, |
96 | 94 | 'Seed' => $description |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | * @package Platine\Framework\Migration\Seed\Command |
65 | 65 | * @template T |
66 | 66 | */ |
67 | -abstract class AbstractSeedCommand extends Command |
|
68 | -{ |
|
67 | +abstract class AbstractSeedCommand extends Command { |
|
69 | 68 | /** |
70 | 69 | * The configuration to use |
71 | 70 | * @var Config<T> |
@@ -100,7 +99,7 @@ discard block |
||
100 | 99 | Application $app, |
101 | 100 | Config $config, |
102 | 101 | Filesystem $filesystem |
103 | - ) { |
|
102 | + ) { |
|
104 | 103 | parent::__construct('seed', 'Command to manage database seed'); |
105 | 104 | $this->application = $app; |
106 | 105 | $this->config = $config; |
@@ -117,7 +116,7 @@ discard block |
||
117 | 116 | { |
118 | 117 | $directory = $this->filesystem->directory($this->seedPath); |
119 | 118 | |
120 | - if (!$directory->exists() || !$directory->isWritable()) { |
|
119 | + if (!$directory->exists() || !$directory->isWritable()) { |
|
121 | 120 | throw new RuntimeException(sprintf( |
122 | 121 | 'Seed directory [%s] does not exist or is writable', |
123 | 122 | $this->seedPath |
@@ -141,7 +140,7 @@ discard block |
||
141 | 140 | $file = $this->filesystem->file($fullPath); |
142 | 141 | $fullClassName = 'Platine\\Framework\\Migration\\Seed\\' . $className; |
143 | 142 | |
144 | - if (!$file->exists()) { |
|
143 | + if (!$file->exists()) { |
|
145 | 144 | throw new RuntimeException(sprintf( |
146 | 145 | 'Seed file [%s] does not exist', |
147 | 146 | $fullPath |
@@ -150,7 +149,7 @@ discard block |
||
150 | 149 | |
151 | 150 | require_once $fullPath; |
152 | 151 | |
153 | - if (!class_exists($fullClassName)) { |
|
152 | + if (!class_exists($fullClassName)) { |
|
154 | 153 | throw new RuntimeException(sprintf( |
155 | 154 | 'Seed class [%s] does not exist', |
156 | 155 | $fullClassName |
@@ -176,9 +175,9 @@ discard block |
||
176 | 175 | $result = []; |
177 | 176 | /** @var FileInterface[] $files */ |
178 | 177 | $files = $directory->read(DirectoryInterface::FILE); |
179 | - foreach ($files as $file) { |
|
178 | + foreach ($files as $file) { |
|
180 | 179 | $matches = []; |
181 | - if (preg_match('/^([a-z]+)Seed\.php$/i', $file->getName(), $matches)) { |
|
180 | + if (preg_match('/^([a-z]+)Seed\.php$/i', $file->getName(), $matches)) { |
|
182 | 181 | $result[Str::camel($matches[1])] = str_replace('_', ' ', Str::snake($matches[1])); |
183 | 182 | } |
184 | 183 | } |
@@ -196,7 +195,7 @@ discard block |
||
196 | 195 | protected function getSeedClassName(string $description): string |
197 | 196 | { |
198 | 197 | $desc = Str::camel($description, false); |
199 | - if (!Str::endsWith('Seed', $desc)) { |
|
198 | + if (!Str::endsWith('Seed', $desc)) { |
|
200 | 199 | $desc .= 'Seed'; |
201 | 200 | } |
202 | 201 | return $desc; |
@@ -105,7 +105,7 @@ |
||
105 | 105 | $this->queryBuilder = $queryBuilder; |
106 | 106 | |
107 | 107 | $this->setName('seed:createdb') |
108 | - ->setDescription('Create a new seed using existing data'); |
|
108 | + ->setDescription('Create a new seed using existing data'); |
|
109 | 109 | |
110 | 110 | $this->addArgument('table', 'name of the table', null, true, false); |
111 | 111 | $this->addArgument('name', 'name of seed', null, false, true); |
@@ -63,8 +63,7 @@ discard block |
||
63 | 63 | * @template T |
64 | 64 | * @extends AbstractSeedCommand<T> |
65 | 65 | */ |
66 | -class SeedCreateDbCommand extends AbstractSeedCommand |
|
67 | -{ |
|
66 | +class SeedCreateDbCommand extends AbstractSeedCommand { |
|
68 | 67 | /** |
69 | 68 | * The seed name |
70 | 69 | * @var string |
@@ -99,7 +98,7 @@ discard block |
||
99 | 98 | Filesystem $filesystem, |
100 | 99 | Schema $schema, |
101 | 100 | QueryBuilder $queryBuilder |
102 | - ) { |
|
101 | + ) { |
|
103 | 102 | parent::__construct($app, $config, $filesystem); |
104 | 103 | $this->schema = $schema; |
105 | 104 | $this->queryBuilder = $queryBuilder; |
@@ -114,8 +113,7 @@ discard block |
||
114 | 113 | /** |
115 | 114 | * {@inheritdoc} |
116 | 115 | */ |
117 | - public function execute() |
|
118 | - { |
|
116 | + public function execute() { |
|
119 | 117 | $writer = $this->io()->writer(); |
120 | 118 | |
121 | 119 | $this->table = $this->getArgumentValue('table'); |
@@ -138,8 +136,8 @@ discard block |
||
138 | 136 | |
139 | 137 | $io = $this->io(); |
140 | 138 | |
141 | - if ($io->confirm('Are you confirm the generation of new seed?', 'n')) { |
|
142 | - if (!$this->schema->hasTable($this->table, true)) { |
|
139 | + if ($io->confirm('Are you confirm the generation of new seed?', 'n')) { |
|
140 | + if (!$this->schema->hasTable($this->table, true)) { |
|
143 | 141 | $writer->boldRed(sprintf( |
144 | 142 | 'Database table [%s] does not exist', |
145 | 143 | $this->table |
@@ -163,7 +161,7 @@ discard block |
||
163 | 161 | $writer->boldYellow('SEED GENERATION USING EXISTING DATA', true)->eol(); |
164 | 162 | |
165 | 163 | $name = $this->getArgumentValue('name'); |
166 | - if (!$name) { |
|
164 | + if (!$name) { |
|
167 | 165 | $io = $this->io(); |
168 | 166 | $name = $io->prompt('Enter the name of the seed', 'Seed description'); |
169 | 167 | } |
@@ -225,7 +223,7 @@ discard block |
||
225 | 223 | ->fetchAssoc() |
226 | 224 | ->all(); |
227 | 225 | |
228 | - if (empty($data)) { |
|
226 | + if (empty($data)) { |
|
229 | 227 | return sprintf('// No data found on table "%s"', $this->table); |
230 | 228 | } |
231 | 229 |