Skip to content

Commit

Permalink
revert variadic $items dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-rubel committed Mar 24, 2022
1 parent ebbc7ca commit eb1d9ac
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/Collection/LocaleNumberFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class LocaleNumberFormatter implements Formatter
*/
public function format(Collection $items): string
{
$items = $this->getFirstFrom($items);

$formatter = new NumberFormatter(
$items->get($this->locale_key) ?? app()->getLocale(),
$items->get($this->style_key) ?? NumberFormatter::DECIMAL
Expand Down
8 changes: 3 additions & 5 deletions src/Collection/TaxNumberFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ class TaxNumberFormatter implements Formatter
*/
public function format(Collection $items): string
{
$instance = $this->getFirstFrom($items);
$tax_number = $this->cleanupTaxNumber($items);

$tax_number = $this->cleanupTaxNumber($instance);

return empty($instance->get($this->country_key))
return empty($items->get($this->country_key))
? $tax_number
: $this->getFullTaxNumber(
$tax_number,
$this->getCountry($instance)
$this->getCountry($items)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @return mixed
*/
function format(string $formatter, mixed ...$items): mixed
function format(string $formatter, mixed $items): mixed
{
$formatter = class_exists($formatter) || interface_exists($formatter)
? app($formatter)
Expand Down
2 changes: 1 addition & 1 deletion tests/DateFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testCanFormatWithTimezone()
Carbon::setTestNow('2022-03-24 23:30');
config(['app.timezone' => 'Europe/Warsaw']);

$result = format('date', now(), 'UTC');
$result = format('date', [now(), 'UTC']);
$this->assertEquals('2022-03-24', $result);

$result = format('date', now());
Expand Down
2 changes: 1 addition & 1 deletion tests/DateTimeFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testCanFormatWithTimezone()
Carbon::setTestNow('2022-03-24 10:30');
config(['app.timezone' => 'Europe/Warsaw']);

$result = format('date-time', now(), 'UTC');
$result = format('date-time', [now(), 'UTC']);
$this->assertEquals('2022-03-24 10:30', $result);

$result = format('date-time', now());
Expand Down

0 comments on commit eb1d9ac

Please sign in to comment.