coduo / php-to-string
Simple library that converts PHP value into strings
Installs: 2 142 974
Dependents: 6
Suggesters: 0
Security: 0
Stars: 210
Watchers: 4
Forks: 6
Open Issues: 0
Requires
- php: >=7.2
- symfony/intl: ^3.4|^4.0|^5.0
Requires (Dev)
- phpspec/phpspec: ^6
README
Simple library that converts PHP values into strings.
Status:
Simple library that allows you to cast any php value into string
Installation
composer require coduo/php-to-string
Usage
Supported types:
- string
- integer
- float/double
- object
- callable
- array
- resource
use Coduo\ToString\StringConverter; $double = new StringConverter(1.12312); echo $double; // "1.12312" $datetime = new StringConverter(new \DateTime()); echo $datetime; // "\DateTime" $array = new StringConverter(array('foo', 'bar', 'baz')); echo $array; // "Array(3)" $res = fopen(sys_get_temp_dir() . "/foo", "w"); $resource = new StringConverter($res); echo $resource; // "Resource(stream)"