Skip to content

Commit

Permalink
add temperature conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ket sakda authored and ket sakda committed Apr 27, 2021
1 parent 849823c commit f7cff58
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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

## 1.1.0 - 2021-04-27

- Add Temerature Conversion
## 1.0.0 - 2021-04-27

- initial release
22 changes: 22 additions & 0 deletions src/Temerature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace Ketsakda\UnitConversions;

class Temerature
{
private float $celsius;

public function __construct(float $celsius)
{
$this->celsius = $celsius;
}

public static function forCelsius(float $celsius) : self
{
return new static($celsius);
}

public function toFahrenheit(): float
{
return ($this->celsius * 1.8) + 32;
}
}
15 changes: 15 additions & 0 deletions tests/TemeratureTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Ketsakda\UnitConversions\Tests;

use Ketsakda\UnitConversions\Temerature;
use PHPUnit\Framework\TestCase;

class TemeratureTest extends TestCase
{
public function test_it_can_convert_celsius_to_fahrenheit()
{
$fahrenheit = Temerature::forCelsius(100)->toFahrenheit();
$this->assertEquals(212, $fahrenheit);
}
}

0 comments on commit f7cff58

Please sign in to comment.