generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ket sakda
authored and
ket sakda
committed
Apr 27, 2021
1 parent
849823c
commit f7cff58
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |