afpinedac/common-value-objects

A collection of reusable value objects for PHP

dev-main 2025-02-28 02:08 UTC

This package is not auto-updated.

Last update: 2025-08-30 01:38:59 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
Email 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!