File tree 3 files changed +40
-0
lines changed
3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All notable changes to ` unit-conversions ` will be documented in this file.
4
4
5
+ ## 1.1.0 - 2021-04-27
6
+
7
+ - Add Temerature Conversion
5
8
## 1.0.0 - 2021-04-27
6
9
7
10
- initial release
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace Ketsakda \UnitConversions ;
3
+
4
+ class Temerature
5
+ {
6
+ private float $ celsius ;
7
+
8
+ public function __construct (float $ celsius )
9
+ {
10
+ $ this ->celsius = $ celsius ;
11
+ }
12
+
13
+ public static function forCelsius (float $ celsius ) : self
14
+ {
15
+ return new static ($ celsius );
16
+ }
17
+
18
+ public function toFahrenheit (): float
19
+ {
20
+ return ($ this ->celsius * 1.8 ) + 32 ;
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Ketsakda \UnitConversions \Tests ;
4
+
5
+ use Ketsakda \UnitConversions \Temerature ;
6
+ use PHPUnit \Framework \TestCase ;
7
+
8
+ class TemeratureTest extends TestCase
9
+ {
10
+ public function test_it_can_convert_celsius_to_fahrenheit ()
11
+ {
12
+ $ fahrenheit = Temerature::forCelsius (100 )->toFahrenheit ();
13
+ $ this ->assertEquals (212 , $ fahrenheit );
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments