Open pointybeard opened 1 year ago
Looks like BinaryCalculator already has an assertion:
So, it seems it just a matter of changing composer.json. ext-intl
and ext-bcmath
could be put into the suggest
block of composer.json. E.g.
"suggest": {
"ext-bcmath": "Needed to enable usage of BinaryCalculator",
"ext-intl": "Needed to support spellout() feature of UnitConverter"
}
Currently, there is a requirement for
ext-bcmath
to be installed:https://github.com/jordanbrauer/unit-converter/blob/a8732503f8e0c6038c805e1449dc498162bfc9a2/composer.json#L12-L16
However, it is possible to use
SimpleCalculator
instead ofBinaryCalculator
:https://github.com/jordanbrauer/unit-converter/blob/a8732503f8e0c6038c805e1449dc498162bfc9a2/src/Unit/AbstractUnit.php#L128-L135
To give flexibility, and support systems that do not or cannot install
php-bcmath
, I suggest adding some assertions inAbstractUnit::as()
or inBinaryCalculator
to check that thebcmath
extension is installed if someone is attempting to use the BinaryCalculator.It appears this is approach is already taken for
ext-intl
here.