2017 © Pedro Peláez
 

library shaper

Abstract transformers for collections and arrays.

image

aviator/shaper

Abstract transformers for collections and arrays.

  • Friday, December 8, 2017
  • by danielsdeboer
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version License, (*1)

Overview

Shaper provides an interface and abstract classes which can be extended to create array or collection shaper classes. These classes can then be reused to shape the same sort of iterable, eg when preparing for serialization., (*2)

Installation

Via Composer:, (*3)

composer require aviator/shaper

Testing

Via Composer:, (*4)

composer test

Usage

Extend either the collection or array shaper and define a public method called shaper():, (*5)

public function shaper ($item)
{
    return [
        'mutated_name' => ucfirst($item['name')
    ];
}

This callback can do whatever you like. Once you've defined your class, you can instantiate it and call shape(), which maps over your iterable and applies the callback:, (*6)

$shaper = new MyArrayShaper($array);
$shaped = $shaper->shape();

You can also set the iterable after instantiation:, (*7)

$shaper = new MyArrayShaper();

// Returns null
$shaper->get();

$shaper->set($yourArray);

// Returns the array
$shaper->get(); 

Other

License

This package is licensed with the MIT License (MIT)., (*8)

The Versions

08/12 2017

dev-master

9999999-dev https://github.com/danielsdeboer/shaper

Abstract transformers for collections and arrays.

  Sources   Download

MIT

The Requires

 

The Development Requires

php arrays collections php7 transformer shaper

08/12 2017

0.1.5

0.1.5.0 https://github.com/danielsdeboer/shaper

Abstract transformers for collections and arrays.

  Sources   Download

MIT

The Requires

 

The Development Requires

php arrays collections php7 transformer shaper

08/12 2017

dev-add-array-item

dev-add-array-item https://github.com/danielsdeboer/shaper

Abstract transformers for collections and arrays.

  Sources   Download

MIT

The Requires

 

The Development Requires

php arrays collections php7 transformer shaper

04/12 2017

0.1.4

0.1.4.0 https://github.com/danielsdeboer/shaper

Abstract transformers for collections and arrays.

  Sources   Download

MIT

The Requires

 

The Development Requires

php arrays collections php7 transformer shaper

01/12 2017

0.1.3

0.1.3.0 https://github.com/danielsdeboer/shaper

Abstract transformers for collections and arrays.

  Sources   Download

MIT

The Requires

 

The Development Requires

php arrays collections php7 transformer shaper

01/12 2017

0.1.2

0.1.2.0 https://github.com/danielsdeboer/shaper

Abstract transformers for collections and arrays.

  Sources   Download

MIT

The Requires

 

The Development Requires

php arrays collections php7 transformer shaper

30/11 2017

0.1.1

0.1.1.0 https://github.com/danielsdeboer/shaper

Abstract transformers for collections and arrays.

  Sources   Download

MIT

The Requires

 

The Development Requires

php arrays collections php7 transformer shaper

30/11 2017

0.1.0

0.1.0.0 https://github.com/danielsdeboer/shaper

Abstract transformers for collections and arrays.

  Sources   Download

MIT

The Requires

 

The Development Requires

php arrays collections php7 transformer shaper