Skip to content

Commit

Permalink
Add README with a short doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tonicospinelli committed Aug 11, 2017
1 parent 8a7c7a6 commit 5a90e16
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions README.md
@@ -0,0 +1,67 @@
Doctrine Types for Brazilian Documents
==========================================

[![Build Status](https://travis-ci.org/brazanation/php-documents-doctrine-types.svg?branch=master)](https://travis-ci.org/brazanation/php-documents-doctrine-types)
[![StyleCI](https://styleci.io/repos/99854995/shield?branch=master)](https://styleci.io/repos/99854995)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/brazanation/php-documents-doctrine-types/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/brazanation/php-documents-doctrine-types/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/brazanation/php-documents-doctrine-types/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/brazanation/php-documents-doctrine-types/?branch=master)


### Installation

```sh
composer require brazanation/document-doctrine-types dev-master
```

### How to Use?

First of all, register the Document Types after Doctrine Connection.

```php
// bootstrap.php

// ... other code
$connection = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, new \Doctrine\Common\EventManager());

\Brazanation\Doctrine\TypeExtension::register($connection);

// ... more code
```

Define the entity's property as the document

```php
/**
* @Entity @Table(name="persons")
*/
class Person
{
/**
* @Id
* @Column(type="cpf")
* @var \Brazanation\Documents\Cpf
*/
private $cpf;

/**
* Person constructor.
* @param \Brazanation\Documents\Cpf $cpf
*/
public function __construct(\Brazanation\Documents\Cpf $cpf)
{
$this->cpf = $cpf;
}

/**
* @return \Brazanation\Documents\Cpf
*/
public function getCpf()
{
return $this->cpf;
}
}
```

### Available Types

* CPF (Registration of individuals or Tax Identification)

0 comments on commit 5a90e16

Please sign in to comment.