2017 © Pedro Peláez
 

library hydration-mapper

image

stratadox/hydration-mapper

  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Hydration Mapper

Build Status Coverage Status Infection Minimum PhpStan Level Scrutinizer Code Quality Maintainability Latest Stable Version License, (*1)

Implements Latest Stable Version License, (*2)

Mapping builder for hydration purposes; maps array or array-like data structures to object properties, in order to assemble the objects that model a business domain., (*3)

Usage sample

<?php

$hydrator = Mapper::forThe(Book::class)
     ->property('title', Has::one(Title::class)
        ->with('title')
     )
     ->property('isbn', Has::one(Isbn::class)
         ->with('code', In::key('id'))
         ->with('version', Call::the(function ($data) {
             return strlen($data['id']);
         }))
     )
     ->property('author', Has::one(Author::class)
         ->with('firstName', In::key('author_first_name'))
         ->with('lastName', In::key('author_last_name'))
     )
     ->property('contents', Has::many(ChapterProxy::class)
         ->containedInA(Chapters::class)
         ->loadedBy(new ChapterLoaderFactory)
     )
     ->property('format')
     ->finish();

Installation

Install using composer:, (*4)

composer require stratadox/hydration-mapper, (*5)

More details

For more information, view the Hydrate repository, (*6)

The Versions