darkfriend/php5-type

There is no license information available for the latest version (1.0.1) of this package.

PHP5-helper for type data

1.0.1 2019-12-23 09:25 UTC

This package is auto-updated.

Last update: 2024-11-08 19:37:00 UTC


README

composer require darkfriend/php5-type

  • TypeHelper::toStrictType($value) - return $value to strict type

Example

use \darkfriend\helpers\TypeHelper;

var_dump(
    TypeHelper::toStrict('false'), // bool(false)
    TypeHelper::toStrict(null), // NULL
    TypeHelper::toStrict(0), // int(0)
    TypeHelper::toStrict('0'), // int(0)
    TypeHelper::toStrict('1'), // int(1)
    TypeHelper::toStrict(1), // int(1)
    TypeHelper::toStrict('1.1'), // float(1.1)
    TypeHelper::toStrict(1.1), // float(1.1)
    TypeHelper::toStrict(true), // bool(true)
    TypeHelper::toStrict(false), // bool(false)
    TypeHelper::toStrict('my string'), // string(9) "my string"
    TypeHelper::toStrict('') // string(0) ""
);