Elgg
Version master
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
classes
Elgg
I18n
Locale.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Elgg\I18n
;
4
5
use
Elgg\Exceptions\I18n\InvalidLocaleException
;
6
13
final
class
Locale
{
14
20
private
function
__construct(
private
string
$locale) {
21
}
22
26
public
function
__toString
() {
27
return
$this->locale;
28
}
29
39
public
static
function
parse
(
string
$locale):
Locale
{
40
if
(!
preg_match
(
'~^[a-z0-9_]{2,20}$~'
, $locale)) {
41
throw
new
InvalidLocaleException
(
"Unrecognized locale: {$locale}"
);
42
}
43
44
return
new
Locale
($locale);
45
}
46
}
Elgg\Exceptions\I18n\InvalidLocaleException
Indicated an invalid Locale was given.
Definition:
InvalidLocaleException.php:12
Elgg\I18n\Locale\__toString
__toString()
Definition:
Locale.php:26
Elgg\I18n\Locale
Language class to ensure only valid languages are used.
Definition:
Locale.php:13
InvalidLocaleException
Elgg\I18n
Definition:
DateTime.php:3
Elgg\I18n\Locale\parse
static parse(string $locale)
Create a language, asserting that the language code is valid.
Definition:
Locale.php:39
preg_match
Generated on Sat Dec 21 2024 00:02:51 for Elgg by
1.8.11