1. Go to this page and download the library: Download brucegithub/minimal-vo 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/ */
brucegithub / minimal-vo example snippets
namespace Tests\Example;
use MinimalVo\BaseValueObject\AbstractVo;
/**
* @template-extends AbstractVo<bool,CustomVo>
*/
class CustomVo extends AbstractVo
{
public function __construct(bool $value, protected string $value2)
{
parent::__construct($value);
}
public function equal($vo): bool
{
if ($this->value === $vo->value &&
$this->value2 === $vo->value2) {
return true;
}
return false;
}
public function valid(): bool
{
if ($this->value && $this->value2) {
return true;
}
return false;
}
public function duplicate()
{
return new self($this->value, $this->value2);
}
}
namespace Tests\Example;
use MinimalVo\BaseValueObject\AbstractVo;
use MinimalVo\BaseValueObject\IntegerVo;
/**
* @template-extends AbstractVo<IntegerVo,CustomVoOfVo>
*/
class CustomVoOfVo extends AbstractVo
{
public function __construct(IntegerVo $value, protected int $value2)
{
parent::__construct($value);
}
public function equal($vo): bool
{
if ($this->value === $vo->toValue() &&
$this->value2 === $vo->value2) {
return true;
}
return false;
}
public function valid(): bool
{
if ($this->value->toValue() >1 && $this->value2>1) {
return true;
}
return false;
}
public function duplicate()
{
return new self($this->value, $this->value2);
}
}
namespace Tests\Example;
use MinimalVo\BaseValueObject\AbstractVo;
/**
* @template-extends AbstractVo<\DateTimeImmutable,CustomDateTimeVo>
*/
class CustomDateTimeVo extends AbstractVo
{
public function __construct(\DateTimeImmutable $value)
{
parent::__construct($value);
}
public function equal($vo): bool
{
if ($this->value === $vo->toValue()) {
return true;
}
return false;
}
public function valid(): bool
{
return false;
}
public function duplicate()
{
return new self($this->value);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.