Last active
July 2, 2017 13:15
-
-
Save Gemorroj/f1a5ccc98d90615a3bf754b839b04300 to your computer and use it in GitHub Desktop.
Litipk\BigNumber
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
<?php | |
namespace Litipk\BigNumbers; | |
class Decimal | |
{ | |
public static function fromInteger(int $intValue): Decimal // notify IDE Decimal object | |
{ | |
self::paramsValidation($intValue, null); | |
return new static((string)$intValue, 0); // use static (not self). Price object, not Decimal | |
} | |
} |
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
<?php | |
namespace App\Entity; | |
use Litipk\BigNumbers\Decimal; | |
class Price extends Decimal | |
{ | |
public function getValue() | |
{ | |
return (string)$this; | |
} | |
} | |
$price = Price::fromInteger(123); // Price object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment