Skip to content

Commit fee35d7

Browse files
Cs fixer
1 parent 7e2f950 commit fee35d7

24 files changed

+46
-78
lines changed

src/Options.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
use Illuminate\Database\Eloquent\Model;
1313
use Illuminate\Database\Eloquent\Relations\Relation;
1414
use Illuminate\Support\Collection;
15-
use JetBrains\PhpStorm\Internal\TentativeType;
1615
use JsonSerializable;
1716
use MyCLabs\Enum\Enum as MyclabsEnum;
18-
use Nette\Utils\Json;
1917
use Spatie\Enum\Enum as SpatieEnum;
2018
use Spatie\LaravelOptions\Providers\ArrayProvider;
2119
use Spatie\LaravelOptions\Providers\AsyncModelProvider;
@@ -27,7 +25,6 @@
2725
use Spatie\LaravelOptions\Providers\SpatieEnumProvider;
2826
use Spatie\LaravelOptions\Providers\SpatieStateProvider;
2927
use Stringable;
30-
use UnitEnum;
3128

3229
class Options implements Arrayable, Jsonable, JsonSerializable, Htmlable, Stringable
3330
{
@@ -165,10 +162,10 @@ public function toArray(): array
165162
{
166163
return $this->provider
167164
->provide()
168-
->when($this->filter instanceof Closure, fn(Collection $collection) => $collection->filter($this->filter))
169-
->when($this->reject instanceof Closure, fn(Collection $collection) => $collection->reject($this->reject))
170-
->when($this->sort instanceof Closure, fn(Collection $collection) => $collection->sortBy($this->sort))
171-
->when($this->unique instanceof Closure, fn(Collection $collection) => $collection->unique($this->sort))
165+
->when($this->filter instanceof Closure, fn (Collection $collection) => $collection->filter($this->filter))
166+
->when($this->reject instanceof Closure, fn (Collection $collection) => $collection->reject($this->reject))
167+
->when($this->sort instanceof Closure, fn (Collection $collection) => $collection->sortBy($this->sort))
168+
->when($this->unique instanceof Closure, fn (Collection $collection) => $collection->unique($this->sort))
172169
->map(function (mixed $item) {
173170
$option = $item instanceof Selectable
174171
? $item->toSelectOption()
@@ -184,17 +181,20 @@ public function toArray(): array
184181

185182
return $option;
186183
})
187-
->when($this->unique === true, fn(Collection $collection) => $collection->unique(
188-
fn(SelectOption $option) => $option->value
184+
->when($this->unique === true, fn (Collection $collection) => $collection->unique(
185+
fn (SelectOption $option) => $option->value
189186
))
190187
->push(...$this->pushedOptions)
191-
->when($this->sort === true, fn(Collection $collection) => $collection->sortBy(
192-
fn(SelectOption $option) => $option->label
188+
->when($this->sort === true, fn (Collection $collection) => $collection->sortBy(
189+
fn (SelectOption $option) => $option->label
193190
))
194191
->values()
195-
->when($this->nullable, fn(Collection $collection) => $collection->prepend(new SelectOption(
192+
->when(
193+
$this->nullable,
194+
fn (Collection $collection) => $collection->prepend(new SelectOption(
196195
$this->nullableLabel,
197-
null))
196+
null
197+
))
198198
)
199199
->toArray();
200200
}
@@ -207,7 +207,7 @@ public function toJson($options = 0)
207207
public function toHtml(): string
208208
{
209209
return collect($this->toArray())
210-
->map(fn(string $label, string|int|null $value) => "<option value='{$value}'>{$label}</option>")
210+
->map(fn (string $label, string|int|null $value) => "<option value='{$value}'>{$label}</option>")
211211
->join(PHP_EOL);
212212
}
213213

src/OptionsServiceProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Spatie\LaravelPackageTools\Package;
66
use Spatie\LaravelPackageTools\PackageServiceProvider;
7-
use Spatie\LaravelOptions\Commands\OptionsCommand;
87

98
class OptionsServiceProvider extends PackageServiceProvider
109
{

src/Providers/ArrayProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function provide(): Collection
2424
$items = $items->combine($items);
2525
}
2626

27-
return $items->map(fn($label, $value) => [
27+
return $items->map(fn ($label, $value) => [
2828
'label' => $label,
2929
'value' => $value,
3030
]);

src/Providers/AsyncModelProvider.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@
33
namespace Spatie\LaravelOptions\Providers;
44

55
use Closure;
6-
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
76
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
87
use Illuminate\Database\Eloquent\Model;
9-
use Illuminate\Database\Eloquent\Relations\Relation;
10-
use Illuminate\Database\Query\Builder;
118
use Illuminate\Support\Collection;
12-
use Spatie\LaravelOptions\SelectOption;
13-
use TypeError;
149

1510
class AsyncModelProvider extends ModelProvider
1611
{

src/Providers/EnumProvider.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
namespace Spatie\LaravelOptions\Providers;
44

55
use Closure;
6-
use Illuminate\Support\Collection;
76
use Spatie\LaravelOptions\SelectOption;
8-
use function _PHPStan_59fb0a3b2\React\Promise\reject;
97

108
/**
119
* @template TValue
@@ -43,12 +41,12 @@ public function map(mixed $item): SelectOption
4341
*
4442
* @return string|int
4543
*/
46-
protected abstract function mapValue(mixed $item): string|int;
44+
abstract protected function mapValue(mixed $item): string|int;
4745

4846
/**
4947
* @param TValue $item
5048
*
5149
* @return string
5250
*/
53-
protected abstract function mapDefaultLabel(mixed $item): string;
51+
abstract protected function mapDefaultLabel(mixed $item): string;
5452
}

src/Providers/ModelProvider.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
88
use Illuminate\Database\Eloquent\Model;
99
use Illuminate\Database\Eloquent\Relations\Relation;
10-
use Illuminate\Database\Query\Builder;
1110
use Illuminate\Support\Collection;
1211
use Spatie\LaravelOptions\SelectOption;
13-
use TypeError;
1412

1513
/**
1614
* @implements Provider<Model>
@@ -41,13 +39,13 @@ public function provide(): Collection
4139

4240
public function map(mixed $item): SelectOption
4341
{
44-
$label = match (true){
42+
$label = match (true) {
4543
$this->label === null => $item->name,
4644
is_string($this->label) => $item->{$this->label},
4745
$this->label instanceof Closure => ($this->label)($item)
4846
};
4947

50-
$value = match (true){
48+
$value = match (true) {
5149
$this->value === null => $item->getKey(),
5250
is_string($this->value) => $item->{$this->value},
5351
$this->value instanceof Closure => ($this->value)($item)

src/Providers/MyClabsEnumProvider.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace Spatie\LaravelOptions\Providers;
44

5-
use Illuminate\Database\Eloquent\Model;
65
use Illuminate\Support\Collection;
7-
use Spatie\LaravelOptions\SelectOption;
86

97
/**
108
* @extends \Spatie\LaravelOptions\Providers\EnumProvider<\MyCLabs\Enum\Enum>

src/Providers/NativeEnumProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use BackedEnum;
66
use Illuminate\Support\Collection;
7-
use Spatie\LaravelOptions\SelectOption;
87

98
/**
109
* @extends EnumProvider<BackedEnum>

src/Providers/SpatieStateProvider.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
use Closure;
66
use Illuminate\Database\Eloquent\Model;
77
use Illuminate\Support\Collection;
8-
use Spatie\ModelStates\State;
98
use Spatie\LaravelOptions\SelectOption;
10-
use TypeError;
9+
use Spatie\ModelStates\State;
1110

1211
/**
1312
* @implements Provider<\Spatie\ModelStates\State>
@@ -32,15 +31,16 @@ public function provide(): Collection
3231
$this->states instanceof Collection => $this->states,
3332
};
3433

35-
return collect($states)->map(fn(State|string $state) => $state instanceof State
34+
return collect($states)->map(
35+
fn (State|string $state) => $state instanceof State
3636
? $state
3737
: $this->resolveState($state)
3838
);
3939
}
4040

4141
public function map(mixed $item): SelectOption
4242
{
43-
$label = match (true){
43+
$label = match (true) {
4444
$this->label instanceof Closure => ($this->label)($item),
4545
$this->label !== null && method_exists($item, $this->label) => call_user_func([$item, $this->label]),
4646
$this->label !== null && property_exists($item, $this->label) => $item->{$this->label},
@@ -50,11 +50,10 @@ public function map(mixed $item): SelectOption
5050
return new SelectOption($label, $item::getMorphClass());
5151
}
5252

53-
5453
protected function resolveState(string $class): State
5554
{
56-
$model = $this->model ?? new class () extends Model {
57-
};
55+
$model = $this->model ?? new class () extends Model {
56+
};
5857

5958
return new $class($model);
6059
}

tests/Database/Migrations/2019_02_12_145759_create_characters_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
return new class extends Migration {
7+
return new class () extends Migration {
88
public function up(): void
99
{
1010
Schema::create('characters', function (Blueprint $table): void {

0 commit comments

Comments
 (0)