1 | <?php |
||
14 | final class DecimalConstants |
||
15 | { |
||
16 | /** @var Decimal */ |
||
17 | private static $ZERO = null; |
||
18 | /** @var Decimal */ |
||
19 | private static $ONE = null; |
||
20 | /** @var Decimal */ |
||
21 | private static $NEGATIVE_ONE = null; |
||
22 | |||
23 | /** @var Decimal */ |
||
24 | private static $PI = null; |
||
25 | /** @var Decimal */ |
||
26 | private static $EulerMascheroni = null; |
||
27 | |||
28 | /** @var Decimal */ |
||
29 | private static $GoldenRatio = null; |
||
30 | /** @var Decimal */ |
||
31 | private static $SilverRatio = null; |
||
32 | /** @var Decimal */ |
||
33 | private static $LightSpeed = null; |
||
34 | |||
35 | private function __construct() |
||
36 | { |
||
37 | } |
||
38 | |||
39 | private function __clone() |
||
40 | { |
||
41 | } |
||
42 | |||
43 | 36 | public static function zero(): Decimal |
|
50 | |||
51 | 66 | public static function one(): Decimal |
|
58 | |||
59 | 40 | public static function negativeOne(): Decimal |
|
60 | { |
||
61 | 40 | if (null === self::$NEGATIVE_ONE) { |
|
62 | 1 | self::$NEGATIVE_ONE = Decimal::fromInteger(-1); |
|
63 | } |
||
64 | 40 | return self::$NEGATIVE_ONE; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * Returns the Pi number. |
||
69 | * @return Decimal |
||
70 | */ |
||
71 | 38 | public static function pi(): Decimal |
|
80 | |||
81 | /** |
||
82 | * Returns the Euler's E number. |
||
83 | * @param integer $scale |
||
84 | * @return Decimal |
||
85 | */ |
||
86 | 2 | public static function e(int $scale = 32): Decimal |
|
94 | |||
95 | /** |
||
96 | * Returns the Euler-Mascheroni constant. |
||
97 | * @return Decimal |
||
98 | */ |
||
99 | 1 | public static function eulerMascheroni(): Decimal |
|
108 | |||
109 | /** |
||
110 | * Returns the Golden Ration, also named Phi. |
||
111 | * @return Decimal |
||
112 | */ |
||
113 | 1 | public static function goldenRatio(): Decimal |
|
122 | |||
123 | /** |
||
124 | * Returns the Silver Ratio. |
||
125 | * @return Decimal |
||
126 | */ |
||
127 | 1 | public static function silverRatio(): Decimal |
|
136 | |||
137 | /** |
||
138 | * Returns the Light of Speed measured in meters / second. |
||
139 | * @return Decimal |
||
140 | */ |
||
141 | 1 | public static function lightSpeed(): Decimal |
|
148 | } |
||
149 |