Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 1a43955

Browse files
authored
Merge pull request #50 from agungsantoso/master
Add Silver Ratio Constant. Thanks to @agungsantoso .
2 parents ef221ca + 8de046e commit 1a43955

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/DecimalConstants.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ final class DecimalConstants
2222

2323
private static $GoldenRatio = null;
2424

25+
private static $SilverRatio = null;
26+
2527
private static $LightSpeed = null;
2628

2729
/**
@@ -123,6 +125,20 @@ public static function goldenRatio()
123125
return self::$GoldenRatio;
124126
}
125127

128+
/**
129+
* Returns the Silver Ratio.
130+
* @return Decimal
131+
*/
132+
public static function silverRatio()
133+
{
134+
if (self::$SilverRatio === null) {
135+
self::$SilverRatio = Decimal::fromString(
136+
"2.41421356237309504880168872420970"
137+
);
138+
}
139+
return self::$SilverRatio;
140+
}
141+
126142
/**
127143
* Returns the Light of Speed measured in meters / second.
128144
* @return Decimal

tests/DecimalConstantsTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public function testFiniteAbs()
2323
Decimal::fromString("1.61803398874989484820458683436564")
2424
));
2525

26+
$this->assertTrue(DecimalConstants::silverRatio()->equals(
27+
Decimal::fromString("2.41421356237309504880168872420970")
28+
));
29+
2630
$this->assertTrue(DecimalConstants::lightSpeed()->equals(
2731
Decimal::fromInteger(299792458)
2832
));

0 commit comments

Comments
 (0)