1. Go to this page and download the library: Download hyperized/value-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/ */
hyperized / value-objects example snippets
use Hyperized\ValueObjects\Concretes\Strings\Email;
use Hyperized\ValueObjects\Concretes\Integers\Port;
$email = Email::fromString('[email protected]');
$email->getLocalPart(); // 'user'
$email->getDomain(); // 'example.com'
$port = Port::fromInteger(8080);
$port->getValue(); // 8080
use Hyperized\ValueObjects\Abstracts\Integers\AbstractPositiveInteger;
readonly class UserId extends AbstractPositiveInteger {}
$id = UserId::fromInteger(42);
$id->getValue(); // 42
use Hyperized\ValueObjects\Abstracts\Strings\AbstractEmail;
readonly class CompanyEmail extends AbstractEmail
{
#[\Override]
protected static function validate(string $value): void
{
parent::validate($value);
if (!str_ends_with($value, '@company.com')) {
throw new \InvalidArgumentException('Must be a company email');
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.