Skip to content

Instantly share code, notes, and snippets.

@Gemorroj
Last active July 2, 2017 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gemorroj/f1a5ccc98d90615a3bf754b839b04300 to your computer and use it in GitHub Desktop.
Save Gemorroj/f1a5ccc98d90615a3bf754b839b04300 to your computer and use it in GitHub Desktop.
Litipk\BigNumber
<?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
}
}
<?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