1. Go to this page and download the library: Download tiny-blocks/value-object 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/ */
tiny-blocks / value-object example snippets
declare(strict_types=1);
use TinyBlocks\Vo\ValueObject;
use TinyBlocks\Vo\ValueObjectBehavior;
final readonly class TransactionId implements ValueObject
{
use ValueObjectBehavior;
public function __construct(public string $value)
{
}
}
declare(strict_types=1);
use TinyBlocks\Vo\ValueObject;
use TinyBlocks\Vo\ValueObjectBehavior;
final readonly class TransactionId implements ValueObject
{
use ValueObjectBehavior;
public function __construct(public string $value)
{
}
}
$transactionId = new TransactionId(value: 'e6e2442f-3bd8-421f-9ac2-f9e26ac4abd2');
$otherTransactionId = new TransactionId(value: 'e6e2442f-3bd8-421f-9ac2-f9e26ac4abd2');
# true
$transactionId->equals(other: $otherTransactionId);
declare(strict_types=1);
use TinyBlocks\Vo\ValueObject;
use TinyBlocks\Vo\ValueObjectBehavior;
final readonly class TransactionId implements ValueObject
{
use ValueObjectBehavior;
public function __construct(public string $value)
{
}
}
$transactionId = new TransactionId(value: 'e6e2442f-3bd8-421f-9ac2-f9e26ac4abd2');
$otherTransactionId = new TransactionId(value: 'e6e2442f-3bd8-421f-9ac2-f9e26ac4abd2');
# true
$transactionId->hashCode() === $otherTransactionId->hashCode();
declare(strict_types=1);
use DateTimeImmutable;
use TinyBlocks\Vo\ValueObject;
use TinyBlocks\Vo\ValueObjectBehavior;
final readonly class Moment implements ValueObject
{
use ValueObjectBehavior;
public function __construct(public string $iso8601)
{
}
public static function from(DateTimeImmutable $instant): Moment
{
return new Moment(iso8601: $instant->format(DateTimeImmutable::ATOM));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.