Skip to content

Commit

Permalink
fix: === comparison with default lang
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup committed Apr 29, 2024
1 parent d6fc2db commit 55f0c16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ResourceLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function default(): self
public static function of(?string $str): self
{
if ($str === null || empty($str)) {
return new self('');
return self::default();
}
$code = Locale::getPrimaryLanguage($str);
return new self($code);
Expand Down
9 changes: 9 additions & 0 deletions test/ResourceLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ public function testDefault(): void
$this->assertSame('', $language->code);
}

public function testEqualsDefault(): void
{
$lang = ResourceLanguage::of('');
$this->assertTrue(
ResourceLanguage::default() === $lang,
'empty lang should be equals to default lang'
);
}

public function testOfOnlyLang(): void
{
$language = ResourceLanguage::of('en');
Expand Down

0 comments on commit 55f0c16

Please sign in to comment.