2017 © Pedro Peláez
 

library hydrator

A high performance hydrator for PHP.

image

odan/hydrator

A high performance hydrator for PHP.

  • Sunday, March 25, 2018
  • by odan
  • Repository
  • 2 Watchers
  • 2 Stars
  • 203 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 7 % Grown

The README.md

Hydrator

A high performance hydrator for PHP., (*1)

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads, (*2)

Requirements

  • PHP >= 7.1

Installation

composer require odan/hydrator

Features

  • Array to Object
  • Object to Array

ObjectProperty

Any data key matching a publicly accessible property will be hydrated; any public properties will be used for extraction., (*3)

ClassMethod

Any data key matching a setter method will be called in order to hydrate; any method matching a getter method will be called for extraction., (*4)

Usage

// User entity
class User
{
    public $id;
    public $username;
    public $firstName;
    public $email;
}

// A row from the database
$userRow = [
    'id' => 1,
    'username' => 'admin',
    'first_name' => 'John Doe',
    'email' => 'john@example.com'
];

// Create the hydrator
$hydrator = new \Odan\Hydrator\ObjectProperty();

// Convert array to a new User object (with lower camel case properties)
$user = $hydrator->hydrate($userRow, new User());

print_r($user);

/*
User Object
(
    [id] => 1
    [username] => admin
    [firstName] => John Doe
    [email] => john@example.com
)
*/

// Convert User object to an array with lower camel case keys
$array = $hydrator->extract($user);

print_r($array);

/*
Array
(
    [id] => 1
    [username] => admin
    [first_name] => John Doe
    [email] => john@example.com
)
*/

Alternatives

  • https://github.com/zendframework/zend-hydrator
  • https://github.com/doctrine/DoctrineModule/blob/master/docs/hydrator.md
  • https://github.com/mark-gerarts/automapper-plus

License

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

The Versions

25/03 2018

dev-master

9999999-dev https://github.com/odan/hydrator

A high performance hydrator for PHP.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

array entity object hydrator popo hydration poco

10/03 2018

1.4.1

1.4.1.0 https://github.com/odan/hydrator

A high performance hydrator for PHP.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

array entity object hydrator popo hydration poco

10/03 2018

1.4.0

1.4.0.0 https://github.com/odan/hydrator

A high performance hydrator for PHP.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

array entity object hydrator popo hydration poco

12/02 2018

1.2.2

1.2.2.0 https://github.com/odan/hydrator

A high performance hydrator for PHP.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

array entity object hydrator popo hydration poco

11/02 2018

dev-analysis-zYZ6JG

dev-analysis-zYZ6JG https://github.com/odan/hydrator

A high performance hydrator for PHP.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

array entity object hydrator popo hydration poco

09/02 2018

1.2.0

1.2.0.0 https://github.com/odan/hydrator

A high performance hydrator for PHP.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

array entity object hydrator popo hydration poco

05/10 2017

1.1.0

1.1.0.0 https://github.com/odan/hydrator

A high performance hydrator for PHP.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

array entity object hydrator popo hydration poco

05/10 2017

1.0.0

1.0.0.0 https://github.com/odan/hydrator

A hydrator

  Sources   Download

MIT

The Development Requires

array object hydrator

05/10 2017

0.1.0

0.1.0.0 https://github.com/odan/hydrator

A hydrator

  Sources   Download

MIT

The Development Requires

array object hydrator