afpinedac / common-value-objects
A collection of reusable value objects for PHP
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/afpinedac/common-value-objects
Requires
- php: >=8.0
Requires (Dev)
- pestphp/pest: ^3.7
This package is not auto-updated.
Last update: 2025-10-25 02:18:16 UTC
README
CommonValueObjects is a PHP package that provides a collection of reusable Value Objects for common data types, ensuring immutability, validation, and consistency in your applications.
π Installation
Install the package via Composer:
composer require afpinedac/common-value-objects
π Features
- β Immutable Value Objects for safer data handling.
- β Strict Validation to prevent invalid values.
- β PSR-4 Autoloading for seamless integration.
- β Compatible with PHP 8+.
π Available Value Objects
| Class | Description | 
|---|---|
| Percentage | Represents a percentage value (e.g., 25%) | 
| URL | Represents a valid URL | 
| Represents a valid Email | |
| File | Represents a File | 
π Usage
Example: Using Percentage
use Afpinedac\CommonValueObjects\Numeric\Percentage; $percentage = new Percentage(0.25); echo $percentage->getFormatted(); // Output: 25.00%
Example: Using Latitude
use Afpinedac\CommonValueObjects\Geographic\Latitude; $latitude = new Latitude(40.7128); echo $latitude; // Output: 40.7128
β Running Tests
This package uses PestPHP for testing. To run tests, use:
vendor/bin/pest
π License
This package is released under the MIT License.
π€ Contributing
Contributions are welcome! Feel free to submit pull requests or open issues on GitHub.
π¬ Contact
For questions or feature requests, contact [Your Name] at your.email@example.com.
π Start using CommonValueObjects today to improve data consistency in your PHP projects!