| @@ 151-166 (lines=16) @@ | ||
| 148 | * |
|
| 149 | * @return NumberInterface |
|
| 150 | */ |
|
| 151 | public static function makePi($precision = null) |
|
| 152 | {
|
|
| 153 | ||
| 154 | if (!is_null($precision) && ($precision > 105 || $precision < 1)) {
|
|
| 155 | throw new \InvalidArgumentException('The PI constant cannot have a precision higher than the constant stored (105).');
|
|
| 156 | } |
|
| 157 | ||
| 158 | $pi = self::make(self::IMMUTABLE, self::PI); |
|
| 159 | ||
| 160 | if (!is_null($precision)) {
|
|
| 161 | return $pi->roundToPrecision($precision); |
|
| 162 | } else {
|
|
| 163 | return $pi; |
|
| 164 | } |
|
| 165 | ||
| 166 | } |
|
| 167 | ||
| 168 | /** |
|
| 169 | * @param int|null $precision |
|
| @@ 173-186 (lines=14) @@ | ||
| 170 | * |
|
| 171 | * @return NumberInterface |
|
| 172 | */ |
|
| 173 | public static function makeTau($precision = null) |
|
| 174 | {
|
|
| 175 | if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
|
| 176 | throw new \InvalidArgumentException('The TAU constant cannot have a precision higher than the constant stored (100).');
|
|
| 177 | } |
|
| 178 | ||
| 179 | $tau = self::make(self::IMMUTABLE, self::TAU); |
|
| 180 | ||
| 181 | if (!is_null($tau)) {
|
|
| 182 | return $tau->roundToPrecision($precision); |
|
| 183 | } else {
|
|
| 184 | return $tau; |
|
| 185 | } |
|
| 186 | } |
|
| 187 | ||
| 188 | /** |
|
| 189 | * @param int|null $precision |
|
| @@ 203-218 (lines=16) @@ | ||
| 200 | * |
|
| 201 | * @return NumberInterface |
|
| 202 | */ |
|
| 203 | public static function makeE($precision = null) |
|
| 204 | {
|
|
| 205 | ||
| 206 | if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
|
| 207 | throw new \InvalidArgumentException('The E constant cannot have a precision higher than the constant stored (100).');
|
|
| 208 | } |
|
| 209 | ||
| 210 | $e = self::make(self::IMMUTABLE, self::E); |
|
| 211 | ||
| 212 | if (!is_null($e)) {
|
|
| 213 | return $e->roundToPrecision($precision); |
|
| 214 | } else {
|
|
| 215 | return $e; |
|
| 216 | } |
|
| 217 | ||
| 218 | } |
|
| 219 | ||
| 220 | /** |
|
| 221 | * @param int|null $precision |
|
| @@ 225-240 (lines=16) @@ | ||
| 222 | * |
|
| 223 | * @return NumberInterface |
|
| 224 | */ |
|
| 225 | public static function makeGoldenRatio($precision = null) |
|
| 226 | {
|
|
| 227 | ||
| 228 | if (!is_null($precision) && ($precision > 100 || $precision < 1)) {
|
|
| 229 | throw new \InvalidArgumentException('The Golden Ratio constant cannot have a precision higher than the constant stored (100).');
|
|
| 230 | } |
|
| 231 | ||
| 232 | $goldenRatio = self::make(self::IMMUTABLE, self::GOLDEN_RATIO); |
|
| 233 | ||
| 234 | if (!is_null($precision)) {
|
|
| 235 | return $goldenRatio->roundToPrecision($precision); |
|
| 236 | } else {
|
|
| 237 | return $goldenRatio; |
|
| 238 | } |
|
| 239 | ||
| 240 | } |
|
| 241 | ||
| 242 | /** |
|
| 243 | * @return ImmutableNumber |
|