Download the PHP package jbzoo/simpletypes without Composer
On this page you can find all versions of the php package jbzoo/simpletypes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package simpletypes
JBZoo / SimpleTypes
A universal PHP library for converting and manipulating values with units of measurement including money, weight, length, temperature, volume, area, and more. Features smart parsing, arithmetic operations, unit conversion, and flexible output formatting.
Installation
Features
- Smart Parser: Handles various input formats, decimal symbols, whitespace, and case variations
- Type System: Built-in support for Money, Weight, Length, Temperature, Volume, Area, Time, Info, and Degree
- Arithmetic Operations: Add, subtract, multiply, divide with automatic unit conversion
- Method Chaining: Fluent interface for complex calculations
- Flexible Output: Text, HTML, and input field rendering with customizable formatting
- Configuration: Extensible configuration system for custom types and conversion rules
- Debug Support: Built-in logging and debugging capabilities
Quick Start
Built-in Types
SimpleTypes comes with comprehensive configurations for common measurement types:
- Area - Square meters, feet, acres, hectares, etc.
- Degree - Angular measurements (degrees, radians)
- Info - Digital storage (bytes, KB, MB, GB, TB)
- Length - Meters, feet, miles, kilometers, etc.
- Money - Currency conversion and formatting
- Temperature - Celsius, Fahrenheit, Kelvin, Rankine
- Time - Seconds, minutes, hours, days, etc.
- Volume - Liters, gallons, cubic meters, etc.
- Weight - Grams, kilograms, pounds, ounces, etc.
Custom types can be easily created by extending the base configuration classes.
Smart Parser
The parser automatically handles various input formats and edge cases:
Method Chaining
Perform complex calculations with fluent interface:
Arithmetic Operations
Multiple ways to perform calculations:
Supported Operations:
- Addition and subtraction with automatic unit conversion
- Multiplication and division
- Custom functions via closures
- Sign operations (negative, positive, absolute value)
- Percentage calculations
- Value and unit modifications
- Object cloning
- Unit/currency conversion
- Rounding and formatting
- Comparison operations
- Serialization support
Value Comparison
Compare values with automatic unit conversion:
Using string input with smart parsing:
Percentage Calculations
Calculate percentage differences between values:
Magic Methods
Serialization Support:
String Conversion:
Object Invocation:
Output Formatting
Text Output
HTML Output
Generated HTML (formatted for readability):
HTML Input Fields
Generated HTML (formatted for readability):
Note: The HTML output includes extensive data attributes to enable client-side JavaScript operations without server round-trips.
Custom Configuration
Create custom types by extending the base configuration class. Here's an example for digital storage:
Using Custom Configuration
Output:
Debug and Introspection
Operation History
Track all operations performed on an object:
Internal State
Access raw internal data without formatting:
Object Identification
Value Access
Unit Access
Requirements
- PHP 8.2 or higher
- jbzoo/utils ^7.3
License
MIT License. See LICENSE file for details.