Skip to content

Commit

Permalink
[11.x] feat: add useful defaultLocale and defaultCurrency helpers to …
Browse files Browse the repository at this point in the history
…Number facade (#53101)

* feat: add useful defaultLocale and defaultCurrency helpers to Number facade and tests

* feat: add useful defaultLocale and defaultCurrency helpers to Number facade and tests

* feat: add useful defaultLocale and defaultCurrency helpers to Number facade and tests

* Update Number.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
sts-ryan-holton and taylorotwell authored Oct 10, 2024
1 parent eba8069 commit cdffc89
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Illuminate/Support/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,26 @@ public static function useCurrency(string $currency)
static::$currency = $currency;
}

/**
* Get the default locale.
*
* @return string
*/
public static function defaultLocale()
{
return static::$locale;
}

/**
* Get the default currency.
*
* @return string
*/
public static function defaultCurrency()
{
return static::$currency;
}

/**
* Ensure the "intl" PHP extension is installed.
*
Expand Down
10 changes: 10 additions & 0 deletions tests/Support/SupportNumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

class SupportNumberTest extends TestCase
{
public function testDefaultLocale()
{
$this->assertSame('en', Number::defaultLocale());
}

public function testDefaultCurrency()
{
$this->assertSame('USD', Number::defaultCurrency());
}

#[RequiresPhpExtension('intl')]
public function testFormat()
{
Expand Down

0 comments on commit cdffc89

Please sign in to comment.