nordic/email-address-doctrine

1.0.0 2019-05-02 07:53 UTC

This package is auto-updated.

Last update: 2024-04-29 03:57:18 UTC


README

PHP version Software License Build Status Coverage Status Quality Score

The nordic/email-address-doctrine package provides the ability to use nordic/email-address as a Doctrine field type.

Install

Via Composer

$ composer require nordic/email-address-doctrine

Configuration

To configure Doctrine to use nordic/email-address as a field type, you'll need to set up the following in your bootstrap:

<?php

use Doctrine\DBAL\Types\Type;
use Nordic\EmailAddress\Doctrine\EmailAddressType;

Type::addType(EmailAddressType::EMAIL_ADDRESS, EmailAddressType::CLASS);

// or
Type::addType('email_address', 'Nordic\EmailAddress\Doctrine\EmailAddressType');

Usage

Now you can annotate properties in your entities:

use Doctrine\ORM\Mapping as ORM;
use Nordic\EmailAddress\EmailAddressInterface;

/**
 * @ORM\Entity
 * @ORM\Table(name="contacts")
 */
class Contact
{
    /**
     * @ORM\Column(type="email_address")
     * @var EmailAddressInterface
     */
    private $emailAddress;

    public function getEmailAddress(): EmailAddressInterface
    {
        return $this->emailAddress;
    }
}

Credits

License

The MIT License (MIT). Please see License File for more information.