This repository has been archived by the owner on Apr 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathRUtils.php
82 lines (74 loc) · 1.76 KB
/
RUtils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace php_rutils;
class RUtils
{
//gender constants
const MALE = 1;
const FEMALE = 2;
const NEUTER = 3;
//accuracy for Dt::distanceOfTimeInWords function
const ACCURACY_YEAR = 1;
const ACCURACY_MONTH = 2;
const ACCURACY_DAY = 3;
const ACCURACY_HOUR = 4;
const ACCURACY_MINUTE = 5;
private static $_numeral;
private static $_dt;
private static $_translit;
private static $_typo;
/**
* Plural forms and in-word representation for numerals
* @return \php_rutils\Numeral
*/
public static function numeral()
{
if (self::$_numeral === null) {
self::$_numeral = new Numeral();
}
return self::$_numeral;
}
/**
* Russian dates without locales
* @return \php_rutils\Dt
*/
public static function dt()
{
if (self::$_dt === null) {
self::$_dt = new Dt();
}
return self::$_dt;
}
/**
* Simple transliteration
* @return \php_rutils\Translit
*/
public static function translit()
{
if (self::$_translit === null) {
self::$_translit = new Translit();
}
return self::$_translit;
}
/**
* Russian typography
* @return \php_rutils\Typo
*/
public static function typo()
{
if (self::$_typo === null) {
self::$_typo = new Typo();
}
return self::$_typo;
}
/**
* Format number with russian locale
* @param float $number
* @param int $decimals
* @return string
*/
public static function formatNumber($number, $decimals = 0)
{
$number = number_format($number, $decimals, ',', ' ');
return str_replace(' ', "\xE2\x80\x89", $number);
}
}