1. Go to this page and download the library: Download tleckie/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/ */
tleckie / value-object example snippets
/**
* Class Age
*/
class Age extends ValueObject
{
}
/**
* Class Age
*/
class Age extends ValueObject
{
}
$john = new Age(34);
$mario = new Age(34);
$raquel = new Age("34");
$john->equals($mario); // true
$john->equals($raquel); // false
$john->equals(new FirstName('Mario')); // false
$raquel->value(); // "34"
/**
* Class Age
*/
class Age extends ValueObject
{
/**
* @return int
*/
public function value(): int
{
return parent::value();
}
}
$raquel = new Age("34");
$mario = new Age(34);
$raquel->value(); // int 34
$mario->equals($raquel); // true
(string)$mario; // string "34"
/**
* Class Age
*/
class Age extends NullableValueObject
{
}
// That's all! I hope this helps you
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.