Test Failed
Push — develop ( 70abbc...8213ee )
by nguereza
02:59
created
src/Handler/Error/ErrorHandler.php 1 patch
Braces   +17 added lines, -19 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Migration/MigrationEntity.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Migration/Seed/Command/SeedStatusCommand.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Braces   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,8 +57,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Migration/Seed/Command/AbstractSeedCommand.php 1 patch
Braces   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -64,8 +64,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Migration/Seed/Command/SeedCreateDbCommand.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Migration/Seed/Command/SeedCreateCommand.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
     ) {
81 81
         parent::__construct($app, $config, $filesystem);
82 82
         $this->setName('seed:create')
83
-             ->setDescription('Create a new seed');
83
+                ->setDescription('Create a new seed');
84 84
 
85 85
         $this->addArgument('name', 'name of seed', null, false, true);
86 86
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@  discard block
 block discarded – undo
61 61
  * @template T
62 62
  * @extends AbstractSeedCommand<T>
63 63
  */
64
-class SeedCreateCommand extends AbstractSeedCommand
65
-{
64
+class SeedCreateCommand extends AbstractSeedCommand {
66 65
     /**
67 66
      * The seed name
68 67
      * @var string
@@ -77,7 +76,7 @@  discard block
 block discarded – undo
77 76
         Application $app,
78 77
         Config $config,
79 78
         Filesystem $filesystem
80
-    ) {
79
+    ) {
81 80
         parent::__construct($app, $config, $filesystem);
82 81
         $this->setName('seed:create')
83 82
              ->setDescription('Create a new seed');
@@ -88,8 +87,7 @@  discard block
 block discarded – undo
88 87
     /**
89 88
      * {@inheritdoc}
90 89
      */
91
-    public function execute()
92
-    {
90
+    public function execute() {
93 91
         $writer = $this->io()->writer();
94 92
 
95 93
         $className = $this->getSeedClassName($this->name);
@@ -109,7 +107,7 @@  discard block
 block discarded – undo
109 107
 
110 108
         $io = $this->io();
111 109
 
112
-        if ($io->confirm('Are you confirm the generation of new seed?', 'n')) {
110
+        if ($io->confirm('Are you confirm the generation of new seed?', 'n')) {
113 111
             $this->checkSeedPath();
114 112
             $this->generateClass($fullPath, $className);
115 113
             $writer->boldGreen(sprintf(
@@ -127,7 +125,7 @@  discard block
 block discarded – undo
127 125
         $writer->boldYellow('SEED GENERATION', true)->eol();
128 126
 
129 127
         $name = $this->getArgumentValue('name');
130
-        if (!$name) {
128
+        if (!$name) {
131 129
             $io = $this->io();
132 130
             $name = $io->prompt('Enter the name of the seed', 'Seed description');
133 131
         }
Please login to merge, or discard this patch.
src/Migration/Seed/Command/SeedExecuteCommand.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
     ) {
71 71
         parent::__construct($app, $config, $filesystem);
72 72
         $this->setName('seed:exec')
73
-             ->setDescription('Command to execute seed');
73
+                ->setDescription('Command to execute seed');
74 74
     }
75 75
 
76 76
     /**
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,8 +57,7 @@  discard block
 block discarded – undo
57 57
  * @template T
58 58
  * @extends AbstractSeedCommand<T>
59 59
  */
60
-class SeedExecuteCommand extends AbstractSeedCommand
61
-{
60
+class SeedExecuteCommand extends AbstractSeedCommand {
62 61
     /**
63 62
      * Create new instance
64 63
      * {@inheritdoc}
@@ -67,7 +66,7 @@  discard block
 block discarded – undo
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:exec')
73 72
              ->setDescription('Command to execute seed');
@@ -76,23 +75,22 @@  discard block
 block discarded – undo
76 75
     /**
77 76
      * {@inheritdoc}
78 77
      */
79
-    public function execute()
80
-    {
78
+    public function execute() {
81 79
         $io = $this->io();
82 80
         $writer = $io->writer();
83 81
         $writer->boldYellow('SEED EXECUTION', true)->eol();
84 82
 
85 83
         $seeds = array_values($this->getAvailableSeeds());
86 84
 
87
-        if (empty($seeds)) {
85
+        if (empty($seeds)) {
88 86
             $writer->boldGreen('No seed available for execution');
89
-        } else {
87
+        } else {
90 88
             $choices = [];
91
-            foreach ($seeds as $key => $seed) {
89
+            foreach ($seeds as $key => $seed) {
92 90
                 $choices[$key + 1] = $seed;
93 91
             }
94 92
             $indexes = $io->choices('Choose which seed to execute', $choices, []);
95
-            foreach ($indexes as $index) {
93
+            foreach ($indexes as $index) {
96 94
                 $this->executeSeed($seeds[$index - 1]);
97 95
             }
98 96
         }
Please login to merge, or discard this patch.
src/Migration/Seed/AbstractSeed.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,7 @@
 block discarded – undo
53 53
  * @class AbstractSeed
54 54
  * @package Platine\Framework\Migration\Seed
55 55
  */
56
-abstract class AbstractSeed extends QueryBuilder
57
-{
56
+abstract class AbstractSeed extends QueryBuilder {
58 57
     /**
59 58
      * Run the seed
60 59
      * @return void
Please login to merge, or discard this patch.
src/Migration/Command/MigrationMigrateCommand.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
     ) {
73 73
         parent::__construct($app, $repository, $config, $filesystem);
74 74
         $this->setName('migration:migrate')
75
-             ->setDescription('Upgrade migration to latest');
75
+                ->setDescription('Upgrade migration to latest');
76 76
     }
77 77
 
78 78
     /**
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@  discard block
 block discarded – undo
58 58
  * @template T
59 59
  * @extends AbstractCommand<T>
60 60
  */
61
-class MigrationMigrateCommand extends AbstractCommand
62
-{
61
+class MigrationMigrateCommand extends AbstractCommand {
63 62
     /**
64 63
      * Create new instance
65 64
      * {@inheritdoc}
@@ -69,7 +68,7 @@  discard block
 block discarded – undo
69 68
         MigrationRepository $repository,
70 69
         Config $config,
71 70
         Filesystem $filesystem
72
-    ) {
71
+    ) {
73 72
         parent::__construct($app, $repository, $config, $filesystem);
74 73
         $this->setName('migration:migrate')
75 74
              ->setDescription('Upgrade migration to latest');
@@ -78,8 +77,7 @@  discard block
 block discarded – undo
78 77
     /**
79 78
      * {@inheritdoc}
80 79
      */
81
-    public function execute()
82
-    {
80
+    public function execute() {
83 81
         $io = $this->io();
84 82
         $writer = $io->writer();
85 83
         $writer->boldYellow('MIGRATION UPGRADE TO LATEST', true)->eol();
@@ -88,23 +86,23 @@  discard block
 block discarded – undo
88 86
         $executed = $this->getExecuted();
89 87
         $diff = array_diff_key($migrations, $executed);
90 88
 
91
-        if (empty($diff)) {
89
+        if (empty($diff)) {
92 90
             $writer->boldGreen('Migration already up to date');
93 91
             return;
94 92
         }
95 93
 
96 94
         $writer->bold('Migration list to be upgraded:', true);
97
-        foreach ($diff as $version => $value) {
95
+        foreach ($diff as $version => $value) {
98 96
             $cleanDescription = str_replace('_', ' ', $value);
99 97
             $writer->boldGreen(sprintf(' * %s - %s', $version, $cleanDescription), true);
100 98
         }
101 99
 
102 100
         $writer->write('', true);
103 101
 
104
-        if ($io->confirm('Are you confirm the migration upgrade to latest?', 'n')) {
102
+        if ($io->confirm('Are you confirm the migration upgrade to latest?', 'n')) {
105 103
             /** @var MigrationExecuteCommand<T> $migrationExecute */
106 104
             $migrationExecute = $this->application->get(MigrationExecuteCommand::class);
107
-            foreach ($diff as $version => $description) {
105
+            foreach ($diff as $version => $description) {
108 106
                 $cleanDescription = str_replace('_', ' ', $description);
109 107
                 $version = (string) $version;
110 108
                 $migrationExecute->executeMigrationUp($version, $cleanDescription);
Please login to merge, or discard this patch.