Collator
class Collator
Replacement for PHP's native {@link \Collator} class.
The only methods currently supported in this class are:
- {@link __construct}
- {@link create}
- {@link asort}
- {@link getErrorCode}
- {@link getErrorMessage}
- {@link getLocale}
Constants
FRENCH_COLLATION |
|
ALTERNATE_HANDLING |
|
CASE_FIRST |
|
CASE_LEVEL |
|
NORMALIZATION_MODE |
|
STRENGTH |
|
HIRAGANA_QUATERNARY_MODE |
|
NUMERIC_COLLATION |
|
DEFAULT_VALUE |
|
PRIMARY |
|
SECONDARY |
|
TERTIARY |
|
DEFAULT_STRENGTH |
|
QUATERNARY |
|
IDENTICAL |
|
OFF |
|
ON |
|
SHIFTED |
|
NON_IGNORABLE |
|
LOWER_FIRST |
|
UPPER_FIRST |
|
SORT_REGULAR |
|
SORT_NUMERIC |
|
SORT_STRING |
|
Methods
|
__construct(string $locale) |
|
static Collator |
create(string $locale) Static constructor. |
|
bool |
asort(array $array, int $sortFlag = self::SORT_REGULAR) Sort array maintaining index association. |
|
bool|int |
compare(string $str1, string $str2) Not supported. Compare two Unicode strings. |
|
bool|int |
getAttribute(int $attr) Not supported. Get a value of an integer collator attribute. |
|
int |
getErrorCode() Returns collator's last error code. Always returns the UZEROERROR class constant value. |
|
string |
getErrorMessage() Returns collator's last error message. Always returns the UZEROERROR_MESSAGE class constant value. |
|
string |
getLocale(int $type = Locale::ACTUAL_LOCALE) Returns the collator's locale. |
|
string |
getSortKey(string $string) Not supported. Get sorting key for a string. |
|
bool|int |
getStrength() Not supported. Get current collator's strength. |
|
bool |
setAttribute(int $attr, int $val) Not supported. Set a collator's attribute. |
|
bool |
setStrength(int $strength) Not supported. Set the collator's strength. |
|
bool |
sortWithSortKeys(array $arr) Not supported. Sort array using specified collator and sort keys. |
|
bool |
sort(array $arr, int $sortFlag = self::SORT_REGULAR) Not supported. Sort array using specified collator. |
|
Details
__construct(string $locale)
Parameters
string |
$locale |
The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en") |
Exceptions
static Collator create(string $locale)
Static constructor.
Parameters
string |
$locale |
The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en") |
Return Value
Exceptions
bool asort(array $array, int $sortFlag = self::SORT_REGULAR)
Sort array maintaining index association.
Parameters
array |
$array |
&$array Input array |
int |
$sortFlag |
Flags for sorting, can be one of the following: Collator::SORTREGULAR - compare items normally (don't change types) Collator::SORTNUMERIC - compare items numerically Collator::SORT_STRING - compare items as strings |
Return Value
bool |
True on success or false on failure |
bool|int compare(string $str1, string $str2)
Not supported. Compare two Unicode strings.
Parameters
string |
$str1 |
The first string to compare |
string |
$str2 |
The second string to compare |
Return Value
bool|int |
Return the comparison result or false on failure: 1 if $str1 is greater than $str2 0 if $str1 is equal than $str2 -1 if $str1 is less than $str2 |
Exceptions
See also
http://www.php.net/manual/en/collator.compare.php |
|
bool|int getAttribute(int $attr)
Not supported. Get a value of an integer collator attribute.
Parameters
int |
$attr |
An attribute specifier, one of the attribute constants |
Return Value
bool|int |
The attribute value on success or false on error |
Exceptions
See also
http://www.php.net/manual/en/collator.getattribute.php |
|
int getErrorCode()
Returns collator's last error code. Always returns the UZEROERROR class constant value.
Return Value
int |
The error code from last collator call |
string getErrorMessage()
Returns collator's last error message. Always returns the UZEROERROR_MESSAGE class constant value.
Return Value
string |
The error message from last collator call |
string getLocale(int $type = Locale::ACTUAL_LOCALE)
Returns the collator's locale.
Parameters
int |
$type |
Not supported. The locale name type to return (Locale::VALIDLOCALE or Locale::ACTUALLOCALE) |
Return Value
string |
The locale used to create the collator. Currently always returns "en". |
string getSortKey(string $string)
Not supported. Get sorting key for a string.
Parameters
string |
$string |
The string to produce the key from |
Return Value
string |
The collation key for $string |
Exceptions
See also
http://www.php.net/manual/en/collator.getsortkey.php |
|
bool|int getStrength()
Not supported. Get current collator's strength.
Return Value
bool|int |
The current collator's strength or false on failure |
Exceptions
See also
http://www.php.net/manual/en/collator.getstrength.php |
|
bool setAttribute(int $attr, int $val)
Not supported. Set a collator's attribute.
Parameters
int |
$attr |
An attribute specifier, one of the attribute constants |
int |
$val |
The attribute value, one of the attribute value constants |
Return Value
bool |
True on success or false on failure |
Exceptions
See also
http://www.php.net/manual/en/collator.setattribute.php |
|
bool setStrength(int $strength)
Not supported. Set the collator's strength.
Parameters
int |
$strength |
Strength to set, possible values: Collator::PRIMARY Collator::SECONDARY Collator::TERTIARY Collator::QUATERNARY Collator::IDENTICAL Collator::DEFAULT |
Return Value
bool |
True on success or false on failure |
Exceptions
See also
http://www.php.net/manual/en/collator.setstrength.php |
|
bool sortWithSortKeys(array $arr)
Not supported. Sort array using specified collator and sort keys.
Parameters
array |
$arr |
&$arr Array of strings to sort |
Return Value
bool |
True on success or false on failure |
Exceptions
See also
http://www.php.net/manual/en/collator.sortwithsortkeys.php |
|
bool sort(array $arr, int $sortFlag = self::SORT_REGULAR)
Not supported. Sort array using specified collator.
Parameters
array |
$arr |
&$arr Array of string to sort |
int |
$sortFlag |
Optional sorting type, one of the following: Collator::SORTREGULAR Collator::SORTNUMERIC Collator::SORT_STRING |
Return Value
bool |
True on success or false on failure |
Exceptions
See also
http://www.php.net/manual/en/collator.sort.php |
|