Skip to content

Commit

Permalink
Add types and code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
pelmered committed Dec 5, 2024
1 parent f49e4fb commit f501815
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Infolists/Components/MoneyEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function setUp(): void
});
}

public function short($showCurrencySymbol = true): static
public function short(bool $showCurrencySymbol = true): static
{
$this->formatStateUsing(function (MoneyEntry $component, null|int|string $state) use ($showCurrencySymbol) {
return MoneyFormatter::formatShort(
Expand Down
2 changes: 1 addition & 1 deletion src/Tables/Columns/MoneyColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function setUp(): void
});
}

public function short($showCurrencySymbol = true): static
public function short(bool $showCurrencySymbol = true): static
{
$this->formatStateUsing(function (MoneyColumn $component, null|int|string $state) use ($showCurrencySymbol) {
return MoneyFormatter::formatShort(
Expand Down
13 changes: 6 additions & 7 deletions tests/MoneyEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
$entry = MoneyEntry::make('price')->short();

$component = ComponentContainer::make(InfolistTestComponent::make())
->components([$entry])
->state([$entry->getName() => 123456789]);
->components([$entry])
->state([$entry->getName() => 123456789]);

$entry = $component->getComponent('price');

Expand All @@ -45,8 +45,8 @@
$entry = MoneyEntry::make('price')->short()->decimals(4);

$component = ComponentContainer::make(InfolistTestComponent::make())
->components([$entry])
->state([$entry->getName() => 123456789]);
->components([$entry])
->state([$entry->getName() => 123456789]);

$entry = $component->getComponent('price');

Expand All @@ -65,13 +65,12 @@
expect($entry->formatState($entry->getState()))->toEqual(replaceNonBreakingSpaces('1,23K kr'));
});


it('formats infolist money in sek with no decimals', function () {
$entry = MoneyEntry::make('price')->currency('SEK')->locale('sv_SE')->decimals(0);

$component = ComponentContainer::make(InfolistTestComponent::make())
->components([$entry])
->state([$entry->getName() => 1000000]);
->components([$entry])
->state([$entry->getName() => 1000000]);

$entry = $component->getComponent('price');

Expand Down

0 comments on commit f501815

Please sign in to comment.