Skip to content

Commit

Permalink
LanguageTag: $tag is non-empty-string
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Jan 5, 2024
1 parent 67766d9 commit 3ebee66
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/LanguageTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class LanguageTag
{
/** @var string */
/** @var non-empty-string */
private $tag;

/** @var array<string, string> */
Expand All @@ -26,6 +26,7 @@ public function __construct($tag)
{
Assert::string($tag);
Assert::true((bool) Strings::match($tag, '~^[a-z]{2}\\-[A-Z]{2}\\z~'), 'Invalid language tag.');
Assert::true($tag !== '');

$this->tag = $tag;
}
Expand All @@ -51,7 +52,7 @@ public function isLang($lang)


/**
* @return string
* @return non-empty-string
*/
public function getLang()
{
Expand All @@ -60,7 +61,7 @@ public function getLang()


/**
* @return string
* @return non-empty-string
*/
public function toString()
{
Expand Down

0 comments on commit 3ebee66

Please sign in to comment.