Skip to content

Commit

Permalink
Add Stones
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedFathiM committed May 1, 2024
1 parent 7b0a58b commit ea6f700
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/UnitConversionsClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UnitConversionsClass

public static function convert($grams)
{
return (new static($grams))->toKilograms();
return (new static($grams));
}

public function __construct($grams)
Expand All @@ -20,4 +20,9 @@ public function toKilograms()
{
return self::$grams / 1000;
}

public function toStones()
{
return self::$grams * 0.000157473;
}
}
6 changes: 5 additions & 1 deletion tests/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@


it('1000 grams is equal to 1 kilogram', function () {
expect(UnitConversionsClass::convert(1000))->toEqual(1);
expect(UnitConversionsClass::convert(1000)->toKilograms())->toEqual(1);
});

it('1 grams is equal to 0.000157473 stones', function () {
expect(UnitConversionsClass::convert(1)->toStones())->toEqual(0.000157473);
});

0 comments on commit ea6f700

Please sign in to comment.