2017 © Pedro Peláez
 

library array-keys-case-transform

Simple library to handle words case transformation from array keys

image

deoliveiralucas/array-keys-case-transform

Simple library to handle words case transformation from array keys

  • Friday, May 18, 2018
  • by deoliveiralucas
  • Repository
  • 1 Watchers
  • 2 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

ArrayKeysCaseTransform

Build Status Code Coverage Code Quality License MIT Packagist, (*1)

Simple library to handle words case transformation from array keys., (*2)

Installation

composer require deoliveiralucas/array-keys-case-transform

Usage

use ArrayKeysCaseTransform\ArrayKeys;

$input = [ 'first_key' => 'value' ];

print_r(ArrayKeys::toCamelCase($input));
/*
Output:
Array
(
    [firstKey] => value
)
*/

$input = [ 'firstKey' => 'value' ];

print_r(ArrayKeys::toSnakeCase($input));
/* 
Output:
Array
(
    [first_key] => value
)
*/

Custom format

use ArrayKeysCaseTransform\ArrayKeys;
use ArrayKeysCaseTransform\Transformer\AbstractTransformer;

$input = [ 'firstKey' => 'value' ];

$customTransform = new class extends AbstractTransformer {
    protected function format(string $key) : string {
        return str_replace('Key', 'CustomKey', $key);
    }
};

print_r(ArrayKeys::transform($customTransform, $input));
/* 
Output:
Array
(
    [firstCustomKey] => value
)
*/

Contributing

Please see CONTRIBUTING for details., (*3)

License

ArrayKeysCaseTransform is released under the MIT License. Please see License File for more information., (*4)

The Versions

18/05 2018

dev-master

9999999-dev

Simple library to handle words case transformation from array keys

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lucas de Oliveira

array transform case camelcase snakecase keys

18/05 2018

1.0.0

1.0.0.0

Simple library to handle words case transformation from array keys

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lucas de Oliveira

array transform case camelcase snakecase keys