1. Go to this page and download the library: Download hradigital/php-datatypes 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/ */
hradigital / php-datatypes example snippets
$user = new User([
'id' => 123,
'active' => true,
'name' => ' John Doe ',
]);
echo $user->getId(); // (int) 123
echo $user->isActive(); // (bool) true
echo $user->getName(); // Prints ' John Doe '
echo $user->getName()->trim()->toUpper()->replace(' ', '-'); // Prints 'JOHN-DOE'
echo $user->getName(); // Prints ' John Doe ' again, as Attribute is immutable.
class User extends AbstractValueObject
{
use HasPositiveIntegerIDTrait,
HasActiveTrait,
HasNameTrait;
}