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.
Add the unitConversion and test the github actions with php 8.0
- Loading branch information
1 parent
8da2884
commit 094f7fb
Showing
3 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
<?php | ||
|
||
namespace WeightConversion\UnitConversions; | ||
|
||
class UnitConversionsClass | ||
{ | ||
public static $grams; | ||
|
||
public static function convert($grams) | ||
{ | ||
return (new static($grams))->toKilograms(); | ||
} | ||
|
||
public function __construct($grams) | ||
{ | ||
self::$grams = $grams; | ||
} | ||
|
||
public function toKilograms() | ||
{ | ||
return self::$grams / 1000; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
<?php | ||
|
||
use WeightConversion\UnitConversions\UnitConversionsClass; | ||
|
||
it('can test', function () { | ||
expect(true)->toBeTrue(); | ||
}); | ||
|
||
|
||
it('1000 grams is equal to 1 kilogram', function () { | ||
expect(UnitConversionsClass::convert(1000))->toEqual(1); | ||
}); |