mirror of
https://github.com/ivuorinen/business-data-fetcher.git
synced 2026-02-03 23:43:35 +00:00
feat: parser now writes, added missing fields
updated docs, example, extensive use of Traits with better handling. valid level 9 phpstan codebase.
This commit is contained in:
26
src/Traits/HasLanguage.php
Normal file
26
src/Traits/HasLanguage.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Ivuorinen\BusinessDataFetcher\Traits;
|
||||
|
||||
trait HasLanguage
|
||||
{
|
||||
/**
|
||||
* @see getLanguageString()
|
||||
* @var string|null $language Two letter language code
|
||||
* (e.g. 'fi', 'sv', 'en')
|
||||
*/
|
||||
public ?string $language;
|
||||
|
||||
/**
|
||||
* Get the language code as a string.
|
||||
*/
|
||||
public function getLanguageString(): string
|
||||
{
|
||||
return match ($this->language) {
|
||||
'fi' => 'finnish',
|
||||
'en' => 'english',
|
||||
'sv' => 'swedish',
|
||||
default => 'unknown:' . $this->language,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user