https://github.com/labrodev/php-mixed-converter
PHP utility class that provides methods to convert mixed values to strings, ints or floats.
https://github.com/labrodev/php-mixed-converter
Last synced: 3 days ago
JSON representation
PHP utility class that provides methods to convert mixed values to strings, ints or floats.
- Host: GitHub
- URL: https://github.com/labrodev/php-mixed-converter
- Owner: labrodev
- License: mit
- Created: 2024-08-17T12:40:17.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-08-17T12:55:00.000Z (over 1 year ago)
- Last Synced: 2025-09-27T05:41:31.900Z (4 months ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- Changelog: CHANGELOG.MD
- License: LICENSE
Awesome Lists containing this project
README
# Description
PhpMixedConvert is PHP utility class that provides methods to convert mixed values to strings, ints or floats.
Sometimes there is necessity in a code to ensure that our variable is string, int or float, especially strict types declaration is enabled in the class. On other hand, there is sometimes cases when the exact type is unknown. For example, it happens often in Laravel and probably could happen in any other project/code structure.
So this utility class has 3 static methods to just convert variable with mixed type to certain type depends on context.
P.S. We surely could detect such cases when to convert from mixed to exact type due static analysis (for example, wtih PHPStan).
## Installation
To install the package, run the following command in your Laravel project:
```bash
composer require labrodev/php-mixed-converter
```
## Requirements
- PHP 8.1 or higher
## Configuration
After installing the package, no additional configuration is needed to start using utility.
## Usage
To use the utility, use Utility class in your class and just call existed static methods from it:
```php