Skip to content

darkfriend/php7-type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TypeHelper

composer require darkfriend/php7-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) ""
);