PHP code example of noahlvb / valueobject-bundle

1. Go to this page and download the library: Download noahlvb/valueobject-bundle 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/ */

    

noahlvb / valueobject-bundle example snippets


class EmailAddressType extends ValueObjectType
{
    public function getClassName(): string
    {
        return EmailAddress::class;
    }

    public function getName(): string
    {
        return 'email_address';
    }
}

class EmailAddressForm extends ValueObjectForm
{
    protected function getClassName(): string
    {
        return EmailAddress::class;
    }
}

class EmailAddressForm extends ValueObjectForm
{
    protected function getClassName(): string
    {
        return EmailAddress::class;
    }

    public function getParent()
    {
        return EmailType::class;
    }
}

class EmailAddressConstraint extends ValueObjectConstraint
{
    public $message = 'This email address is not valid.';
}

class EmailAddressConstraintValidator extends ValueObjectConstraintValidator
{
}

class EmailAddressForm extends ValueObjectForm
{
    protected function getConstraintClassName(): string
    {
        return EmailAddressConstraint::class;
    }
}