Skip to content

Commit

Permalink
BugFix namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jun 4, 2022
1 parent 86ceee5 commit 1cbdc7d
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 26 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"autoload": {
"psr-4": {
"Bakame\\Laravel\\Intl\\": "src/"
"Bakame\\Intl\\": "src/"
},
"exclude-from-classmap": [
"src/**Test.php",
Expand Down
8 changes: 4 additions & 4 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl;
namespace Bakame\Intl;

use Bakame\Laravel\Intl\Options\DateType;
use Bakame\Laravel\Intl\Options\NumberStyle;
use Bakame\Laravel\Intl\Options\TimeType;
use Bakame\Intl\Options\DateType;
use Bakame\Intl\Options\NumberStyle;
use Bakame\Intl\Options\TimeType;

final class Configuration
{
Expand Down
2 changes: 1 addition & 1 deletion src/DateResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl;
namespace Bakame\Intl;

use DateTimeInterface;
use DateTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/FailedFormatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl;
namespace Bakame\Intl;

use RuntimeException;
use Throwable;
Expand Down
12 changes: 6 additions & 6 deletions src/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl;
namespace Bakame\Intl;

use Bakame\Laravel\Intl\Options\DateType;
use Bakame\Laravel\Intl\Options\NumberAttribute;
use Bakame\Laravel\Intl\Options\NumberStyle;
use Bakame\Laravel\Intl\Options\NumberType;
use Bakame\Laravel\Intl\Options\TimeType;
use Bakame\Intl\Options\DateType;
use Bakame\Intl\Options\NumberAttribute;
use Bakame\Intl\Options\NumberStyle;
use Bakame\Intl\Options\NumberType;
use Bakame\Intl\Options\TimeType;
use DateTimeInterface;
use DateTimeZone;
use Exception;
Expand Down
106 changes: 104 additions & 2 deletions src/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl;
namespace Bakame\Intl;

use DateTime;
use DateTimeImmutable;
Expand All @@ -12,7 +12,7 @@
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass \Bakame\Laravel\Intl\Formatter
* @coversDefaultClass \Bakame\Intl\Formatter
*/
final class FormatterTest extends TestCase
{
Expand Down Expand Up @@ -151,4 +151,106 @@ public function it_fails_to_format_a_number_with_invalid_attributes_value(): voi

$this->formatter->formatNumber(42, ['grouping_used' => 'foobar']);
}

/**
* @test
* @dataProvider currencyNameProvider
*/
public function it_can_get_the_currency_name(?string $currency, ?string $locale, string $expected): void
{
self::assertSame($expected, $this->formatter->getCurrencyName($currency, $locale));
}

/**
* @return iterable<string, array{currency:?string, locale:?string, expected:string}>
*/
public function currencyNameProvider(): iterable
{
yield 'unknown name' => [
'currency' => 'UNKNOWN',
'locale' => null,
'expected' => 'UNKNOWN',
];

yield 'null value' => [
'currency' => null,
'locale' => null,
'expected' => '',
];

yield 'euro with default locale' => [
'currency' => 'EUR',
'locale' => null,
'expected' => 'Euro',
];

yield 'yen with default locale' => [
'currency' => 'JPY',
'locale' => null,
'expected' => 'Japanese Yen',
];

yield 'euro with french locale' => [
'currency' => 'EUR',
'locale' => 'fr',
'expected' => 'euro',
];

yield 'yen with french from France locale' => [
'currency' => 'JPY',
'locale' => 'fr_FR',
'expected' => 'yen japonais',
];
}

/**
* @test
* @dataProvider countryNameProvider
*/
public function it_can_get_the_country_name(?string $country, ?string $locale, string $expected): void
{
self::assertSame($expected, $this->formatter->getCountryName($country, $locale));
}

/**
* @return iterable<string, array{country:?string, locale:?string, expected:string}>
*/
public function countryNameProvider(): iterable
{
yield 'unknown name' => [
'country' => 'UNKNOWN',
'locale' => null,
'expected' => 'UNKNOWN',
];

yield 'null value' => [
'country' => null,
'locale' => null,
'expected' => '',
];

yield 'France default locale' => [
'country' => 'FR',
'locale' => null,
'expected' => 'France',
];

yield 'US default locale' => [
'country' => 'US',
'locale' => null,
'expected' => 'United States',
];

yield 'US with fr locale' => [
'country' => 'US',
'locale' => 'fr',
'expected' => 'États-Unis',
];

yield 'Swiss with fr canada locale' => [
'country' => 'CH',
'locale' => 'fr_CA',
'expected' => 'Suisse',
];
}
}
2 changes: 1 addition & 1 deletion src/Options/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl\Options;
namespace Bakame\Intl\Options;

use IntlDateFormatter;

Expand Down
4 changes: 2 additions & 2 deletions src/Options/DateTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl\Options;
namespace Bakame\Intl\Options;

use Bakame\Laravel\Intl\FailedFormatting;
use Bakame\Intl\FailedFormatting;
use IntlDateFormatter;
use PHPUnit\Framework\TestCase;

Expand Down
4 changes: 2 additions & 2 deletions src/Options/NumberAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl\Options;
namespace Bakame\Intl\Options;

use Bakame\Laravel\Intl\FailedFormatting;
use Bakame\Intl\FailedFormatting;
use NumberFormatter;

final class NumberAttribute
Expand Down
2 changes: 1 addition & 1 deletion src/Options/NumberStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl\Options;
namespace Bakame\Intl\Options;

use NumberFormatter;

Expand Down
2 changes: 1 addition & 1 deletion src/Options/NumberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl\Options;
namespace Bakame\Intl\Options;

use NumberFormatter;

Expand Down
4 changes: 2 additions & 2 deletions src/Options/PseudoEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl\Options;
namespace Bakame\Intl\Options;

use Bakame\Laravel\Intl\FailedFormatting;
use Bakame\Intl\FailedFormatting;

abstract class PseudoEnum
{
Expand Down
2 changes: 1 addition & 1 deletion src/Options/TimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl\Options;
namespace Bakame\Intl\Options;

use IntlDateFormatter;

Expand Down
2 changes: 1 addition & 1 deletion src/SystemDateResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bakame\Laravel\Intl;
namespace Bakame\Intl;

use DateTime;
use DateTimeImmutable;
Expand Down

0 comments on commit 1cbdc7d

Please sign in to comment.