Skip to content

Commit f7cff58

Browse files
ket sakdaket sakda
ket sakda
authored and
ket sakda
committed
add temperature conversion
1 parent 849823c commit f7cff58

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to `unit-conversions` will be documented in this file.
44

5+
## 1.1.0 - 2021-04-27
6+
7+
- Add Temerature Conversion
58
## 1.0.0 - 2021-04-27
69

710
- initial release

src/Temerature.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

tests/TemeratureTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}

0 commit comments

Comments
 (0)