1. Go to this page and download the library: Download rikudou/scalar-objects library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rikudou / scalar-objects example snippets
use Rikudou\ScalarObjects\TypeHint\IntegerTypehint;
use Rikudou\ScalarObjects\TypeHint\StringTypehint;
e two variables are not actually objects, the typehints
// are just for IDE completion
var_dump($num1->isInt()); // bool(true)
var_dump($num2->isString()); // bool(true)
var_dump($num2->isNumeric()); // bool(true)
var_dump($num2->isNumber()); // bool(false) - isNumber() returns true only for int and float
var_dump($num1->toString()->length()); // int(1)
/** @var StringTypehint $string */
$string = "This is a test string";
var_dump($string->length()); // int(21);
var_dump($string->capitalize()); // string(21) "This Is A Test String"
var_dump($string->caseInsensitiveCompare("this Is a TESt STRInG")); // int(0)
var_dump($string->toUpper()); // string(21) "THIS IS A TEST STRING"
var_dump($string->toLower()); //string(21) "this is a test string"