1. Go to this page and download the library: Download elegant-php/types 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/ */
elegant-php / types example snippets
final class AuthorizedUser implements User
{
public function __construct(
private readonly StringType $name
) { }
}
$user = new AuthorizedUser(new DefaultString('my user'));
final class UserName extends StringType
{
public function __construct(
private readonly string $name
) { }
public function value(): string
{
return strtolower($this->name);
}
}
$first = new DefaultString('first');
$second = new DefaultString('first');
var_dump($first->equals($second));
// bool(false)
$id = new StringAsInteger('123');
var_dump($id->value());
// int(123)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.