library taxonomy
Embedded Annotations with JSON
sergiors/taxonomy
Embedded Annotations with JSON
- Monday, May 2, 2016
- by sergiors
- Repository
- 2 Watchers
- 6 Stars
- 54 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
Taxonomy
, (*1)
Taxonomy is an easier way implements Value Object and persist them in JSON format. Like Doctrine Embeddables, (*2)
Motivation
http://www.postgresql.org/docs/9.5/static/datatype-json.html
https://dev.mysql.com/doc/refman/5.7/en/json.html, (*3)
Install
composer require sergiors/taxonomy "dev-master"
How to use
use Sergiors\Taxonomy\Configuration\Annotation as Taxonomy;
class User
{
/**
* @Taxonomy\Embedded(
* class="Phone",
* column=@Taxonomy\Column(name="phone_metadata")
* )
*/
private $phone;
public function getPhone()
{
return $this->phone;
}
public function setPhone(Phone $phone)
{
$this->phone = $phone;
}
}
/**
* @Taxonomy\Embeddable
*/
class Phone
{
/**
* @Taxonomy\Index
*/
private $number;
/**
* @Taxonomy\Index(name="actived")
*/
private $active;
public function __construct()
{
$this->active = false;
}
public function getNumber()
{
return $this->number;
}
public function isActive()
{
return $this->active;
}
public function setNumber($number)
{
$this->number = preg_replace('/\D+/', '', $number);
}
}
License
MIT, (*4)
dev-master
9999999-dev
Embedded Annotations with JSON
Sources
Download
MIT
The Requires
The Development Requires
by
Sérgio Rafael Siqueira