Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4792907
AcceptedLanguages.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
851 B
Referenced Files
None
Subscribers
None
AcceptedLanguages.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\HTTP\Requests
;
use
Keruald\OmniTools\Collections\WeightedList
;
class
AcceptedLanguages
{
/**
* @var string
*/
private
$acceptedLanguages
;
///
/// Constructor
///
public
function
__construct
(
string
$acceptedLanguages
=
''
)
{
$this
->
acceptedLanguages
=
$acceptedLanguages
;
}
public
static
function
fromServer
()
:
self
{
return
new
self
(
self
::
extractFromHeaders
());
}
///
/// Helper methods to determine the languages
///
public
static
function
extractFromHeaders
()
:
string
{
return
$_SERVER
[
'HTTP_ACCEPT_LANGUAGE'
]
??
""
;
}
public
function
getLanguageCodes
()
:
array
{
return
WeightedList
::
parse
(
$this
->
acceptedLanguages
)
->
toSortedArray
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 21:39 (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2435784
Default Alt Text
AcceptedLanguages.php (851 B)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment