Skip to content

Commit c40e8e3

Browse files
committed
fix formatting
1 parent 0ac8951 commit c40e8e3

File tree

4 files changed

+49
-30
lines changed

4 files changed

+49
-30
lines changed

src/Kickstart/Kickstart.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct(
4545

4646
/**
4747
* @return bool|int
48+
*
4849
* @throws InvalidArgumentException
4950
*/
5051
public function copyDraftToProject()
@@ -57,6 +58,7 @@ public function copyDraftToProject()
5758

5859
/**
5960
* @return void
61+
*
6062
* @throws FileNotFoundException
6163
*/
6264
public function copySeederToProject()
@@ -98,6 +100,7 @@ public function deleteGenericSeeders()
98100

99101
/**
100102
* @return string|null
103+
*
101104
* @throws Throwable
102105
*/
103106
public function missingRequiredMigrationsMessage()

src/Kickstart/Project.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public function __construct(string $basePath, bool $hasTeams)
2727
}
2828

2929
/**
30-
* @return string
30+
* @return string
3131
*
32-
* @throws InvalidArgumentException
32+
* @throws InvalidArgumentException
3333
*/
3434
public function basePath()
3535
{

src/Kickstart/Stub.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Stub
3131
private $controllerType;
3232

3333
/**
34-
* @var array|array[]
34+
* @var array<string, string[]>
3535
*/
3636
private static array $modelNames = [
3737
'blog' => ['Post', 'Comment'],
@@ -49,6 +49,7 @@ public function __construct(string $template, string $controllerType, bool $hasT
4949

5050
/**
5151
* @return false|string
52+
*
5253
* @throws InvalidArgumentException
5354
*/
5455
public function content()
@@ -62,6 +63,7 @@ public function content()
6263

6364
/**
6465
* @return 'none' | 'empty' | 'api' | 'web'
66+
*
6567
* @throws InvalidArgumentException
6668
*/
6769
public function controllerType()
@@ -92,6 +94,7 @@ public function draftPath()
9294

9395
/**
9496
* @return string[]
97+
*
9598
* @throws InvalidArgumentException
9699
*/
97100
public function modelNames()
@@ -109,6 +112,7 @@ public function seederPath()
109112

110113
/**
111114
* @return string
115+
*
112116
* @throws InvalidArgumentException
113117
*/
114118
public function template()
@@ -150,6 +154,7 @@ public function template()
150154

151155
/**
152156
* @return string
157+
*
153158
* @throws InvalidArgumentException
154159
*/
155160
private function controllerContent()
@@ -169,39 +174,48 @@ private function controllerContent()
169174
return '';
170175
}
171176

177+
/**
178+
* @return string
179+
*/
172180
private function emptyControllersContent()
173181
{
174-
$result = "controllers:".PHP_EOL;
182+
$result = 'controllers:'.PHP_EOL;
175183

176184
foreach ($this->modelNames() as $model) {
177185
$result .= " {$model}:".PHP_EOL;
178-
$result .= " resource: none".PHP_EOL;
186+
$result .= ' resource: none'.PHP_EOL;
179187
}
180188

181189
return $result;
182190
}
183191

192+
/**
193+
* @return string
194+
*/
184195
private function apiControllersContent()
185196
{
186-
$result = "controllers:".PHP_EOL;
197+
$result = 'controllers:'.PHP_EOL;
187198
foreach ($this->modelNames() as $model) {
188199
$pluralResource = str($model)->lower()->plural();
189200

190201
$result .= " {$model}:".PHP_EOL;
191-
$result .= " resource: api".PHP_EOL;
192-
$result .= " index:".PHP_EOL;
202+
$result .= ' resource: api'.PHP_EOL;
203+
$result .= ' index:'.PHP_EOL;
193204
$result .= " resource: 'paginate:{$pluralResource}'".PHP_EOL;
194205
}
195206

196207
return $result;
197208
}
198209

210+
/**
211+
* @return string
212+
*/
199213
private function webControllersContent()
200214
{
201-
$result = "controllers:".PHP_EOL;
215+
$result = 'controllers:'.PHP_EOL;
202216
foreach ($this->modelNames() as $model) {
203217
$result .= " {$model}:".PHP_EOL;
204-
$result .= " resource".PHP_EOL;
218+
$result .= ' resource'.PHP_EOL;
205219
}
206220

207221
return $result;

src/NewCommand.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,28 @@ protected function interact(InputInterface $input, OutputInterface $output)
154154
) === 'Pest');
155155
}
156156

157-
if (!version_compare(PHP_VERSION, '7.4.0', '>=')) {
157+
if (! version_compare(PHP_VERSION, '7.4.0', '>=')) {
158158
$output->writeln(' <bg=yellow;fg=black> WARN </> Kickstart options bypassed. PHP >= 7.4 is required'.PHP_EOL);
159159
return;
160160
}
161161

162162
$kickstartTemplate = transform($input->getOption('kickstart'), Str::kebab(...));
163163

164-
if (!in_array($kickstartTemplate, ['none', 'blog', 'podcast', 'phone-book'])) {
164+
if (! in_array($kickstartTemplate, ['none', 'blog', 'podcast', 'phone-book'])) {
165165
$input->setOption('kickstart', select(
166166
label: 'Would you like to kickstart this project with a pre-defined template?',
167167
options: [
168168
'none' => 'None',
169169
'blog' => 'Blog',
170170
'podcast' => 'Podcast',
171-
'phone-book' => 'Phone Book'
171+
'phone-book' => 'Phone Book',
172172
],
173173
default: 'none',
174-
hint: implode(PHP_EOL." ", [
175-
"Eloquent Relationships Included:",
176-
"Blog: BelongsTo, HasMany",
177-
"Podcast: BelongsTo, HasMany, BelongsToMany",
178-
"Phone Book: BelongsTo, 1-to-M Polymorphic, M-to-M Polymorphic"
174+
hint: implode(PHP_EOL.' ', [
175+
'Eloquent Relationships Included:',
176+
'Blog: BelongsTo, HasMany',
177+
'Podcast: BelongsTo, HasMany, BelongsToMany',
178+
'Phone Book: BelongsTo, 1-to-M Polymorphic, M-to-M Polymorphic',
179179
])
180180
));
181181
}
@@ -184,7 +184,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
184184
$stack = $input->getOption('stack');
185185

186186
if ($input->getOption('jet') || (
187-
$input->getOption('breeze') && !in_array($stack, ['api', 'blade'])
187+
$input->getOption('breeze') && ! in_array($stack, ['api', 'blade'])
188188
)) {
189189
$defaultControllerType = 'none';
190190
} elseif ($stack === 'blade') {
@@ -1098,19 +1098,21 @@ protected function pregReplaceInFile(string $pattern, string $replace, string $f
10981098
* @param InputInterface $input
10991099
* @param OutputInterface $output
11001100
* @return void
1101+
*
11011102
* @throws FileNotFoundException
11021103
* @throws Throwable
11031104
*/
11041105
private function runKickstart(bool $ranDefaultMigrations, InputInterface $input, OutputInterface $output)
11051106
{
11061107
$output->writeln('');
1107-
$seed = !$input->isInteractive() || ($ranDefaultMigrations && confirm(
1108-
label: "Run the kickstart seeder for the ".$this->kickstart->stub()->displayName()." template?",
1109-
hint: "Or, run manually: `php artisan db:seed --class=KickstartSeeder`"
1108+
$seed = ! $input->isInteractive() || ($ranDefaultMigrations && confirm(
1109+
label: 'Run the kickstart seeder for the '.$this->kickstart->stub()->displayName().' template?',
1110+
hint: 'Or, run manually: `php artisan db:seed --class=KickstartSeeder`'
11101111
));
11111112

11121113
if (! $this->kickstart->copyDraftToProject()) {
11131114
$output->writeln(' <bg=yellow;fg=black> WARN </> Failed to copy draft.yaml to project. Kickstart disabled...'.PHP_EOL);
1115+
11141116
return;
11151117
}
11161118

@@ -1121,7 +1123,7 @@ private function runKickstart(bool $ranDefaultMigrations, InputInterface $input,
11211123
$this->findComposer().' require laravel-shift/blueprint jasonmccreary/laravel-test-assertions --dev',
11221124
"echo '{$projectPath}/draft.yaml' >> .gitignore",
11231125
"echo '{$projectPath}/.blueprint' >> .gitignore",
1124-
$this->phpBinary()." artisan vendor:publish --tag=blueprint-config",
1126+
$this->phpBinary().' artisan vendor:publish --tag=blueprint-config',
11251127
$this->phpBinary()." artisan blueprint:build {$this->kickstart->project()->draftPath()}",
11261128
]);
11271129

@@ -1132,18 +1134,18 @@ private function runKickstart(bool $ranDefaultMigrations, InputInterface $input,
11321134
$this->kickstart->copySeederToProject();
11331135

11341136
if ($seed) {
1135-
$this->runCommands([$this->phpBinary()." artisan migrate"], $input, $output, workingPath: $projectPath);
1137+
$this->runCommands([$this->phpBinary().' artisan migrate'], $input, $output, workingPath: $projectPath);
11361138

11371139
if ($msg = $this->kickstart->missingRequiredMigrationsMessage()) {
11381140
$output->writeln(' <bg=yellow;fg=black> WARN </> '.$msg.PHP_EOL);
11391141
} else {
1140-
$this->runCommands([$this->phpBinary()." artisan db:seed --class=KickstartSeeder"], $input, $output, workingPath: $projectPath);
1142+
$this->runCommands([$this->phpBinary().' artisan db:seed --class=KickstartSeeder'], $input, $output, workingPath: $projectPath);
11411143
}
11421144
}
11431145

11441146
$this->commitChanges('Kickstart Complete', $projectPath, $input, $output);
11451147

1146-
$output->writeln(" <bg=blue;fg=white> INFO </> Kickstart files created 🚀.".PHP_EOL);
1148+
$output->writeln(' <bg=blue;fg=white> INFO </> Kickstart files created 🚀.'.PHP_EOL);
11471149
}
11481150

11491151
/**
@@ -1152,18 +1154,18 @@ private function runKickstart(bool $ranDefaultMigrations, InputInterface $input,
11521154
*/
11531155
private function installApiCommand(bool $seed)
11541156
{
1155-
if (!$this->usingLaravelVersionOrNewer(11, $this->kickstart->project()->basePath())) {
1157+
if (! $this->usingLaravelVersionOrNewer(11, $this->kickstart->project()->basePath())) {
11561158
return null;
11571159
}
11581160

11591161
if ($this->kickstart->stub()->controllerType() !== 'api') {
11601162
return null;
11611163
}
11621164

1163-
if (!$seed) {
1164-
return $this->phpBinary()." artisan install:api --without-migration-prompt";
1165+
if (! $seed) {
1166+
return $this->phpBinary().' artisan install:api --without-migration-prompt';
11651167
}
11661168

1167-
return $this->phpBinary()." artisan install:api --no-interaction";
1169+
return $this->phpBinary().' artisan install:api --no-interaction';
11681170
}
11691171
}

0 commit comments

Comments
 (0)