PHP code example of aeviiq / value-object
1. Go to this page and download the library: Download aeviiq/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/ */
aeviiq / value-object example snippets
declare(strict_types=1);
namespace Aeviiq\ValueObject\Value;
use Aeviiq\ValueObject\AbstractString;
use Aeviiq\ValueObject\Normalizer;
use Symfony\Component\Validator\Constraints;
final class Iban extends AbstractString
{
public static function getConstraints(): array
{
return [
new Constraints\Iban(),
];
}
protected function normalize($value): string
{
return Normalizer::removeWhitespace($value);
}
}
$iban = new Iban('Invalid value'); // Results in InvalidArgumentException
$iban = new Iban('NL91 ABNA 0417 1643 00'); // Contains a valid Iban.