Add string parsing, humanize(), many unit families, and Laravel integration#4
Merged
Merged
Conversation
…le, and more base units
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds out the four most-requested capabilities to make the library more useful and broaden its reach.
Added
Quantity::parse('100 km/h'),Quantity::parse('-40 °C'), and multi-segmentQuantity::parse('5 ft 3 in')(same-dimension segments are summed).Quantity::humanize()— auto-selects the most readable unit via curated ladders (1500 m→1.5 km,2_500_000 B→2.5 MB), leaving affine temperature units untouched.UnitServiceProviderand an EloquentAsQuantitycast (store a quantity in one column, get aQuantityback; strings are parsed on write). Custom units viaconfig/unit.php.Notes
illuminate/databaseadded torequire-dev(+suggest); the Laravel test skips cleanly when it's absent.B, angleA) is fully typed.Verification
docs/) extended with all new families; conversion math cross-checked against the PHP library.