An open API service indexing awesome lists of open source software.

https://github.com/rostym/hydrator

This is a simple library which provide you possibility to hydrate and extract an object properties (private, protected) without using reflection.
https://github.com/rostym/hydrator

extract-data hydrate hydration hydrator library php

Last synced: 4 months ago
JSON representation

This is a simple library which provide you possibility to hydrate and extract an object properties (private, protected) without using reflection.

Awesome Lists containing this project

README

          

# Hydrator library
[![Build Status](https://travis-ci.org/Krifollk/hydrator.svg?branch=master)](https://travis-ci.org/Krifollk/hydrator)

This is a simple library which provide you possibility to hydrate and extract an object properties (private, protected) without using reflection.

## Requirements
- PHP 7 and higher

## Installation

Install the latest version with

```bash
$ composer require krifollk/hydrator
```

## Usage Example

Example of hydration an object
```php
hydrate($user, ['name' => 'John', 'surname' => 'Doe']);

print_r($user);

```
Output:

```
User Object
(
[name:User:private] => John
[surname:protected] => Doe
)

```
Example of extracting properties from an object

```php
extractProperties($user, ['name', 'surname']);

print_r($result);

```
Output:
```
Array
(
[name] => John
[surname] => Doe
)

```