larapkg/laravel-keychanger

PhpKeyChanger allows you to pass a json string, object or an array and it will recursively re-key the array using the case you give it.

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:project

pkg:composer/larapkg/laravel-keychanger

v1.0.0 2020-08-21 12:16 UTC

This package is auto-updated.

Last update: 2025-10-15 07:11:26 UTC


README

Codacy Badge Build Status

KeyChanger allows you to pass a json string, object or an array and it will recursively re-key it using the case you give it. This package was created to handle situation like $someImportedData->SomeKey so we can use a nice $someImportedData->someKey for example, to assist in readable clean code.

  • Camel Case
  • Pascal Case
  • Snake Case
  • Kebab Case
  • Studly Case

Installation

Note: Php key changer requires php ^7.4

composer require larapkg/laravel-keychanger

Usage

$reKeyed = KeyChanger::reKey($array, 'snake');

You can use any of the above cases, and you can pass in an object, a Json string or an Array, it will be return the same type that you pass in.

Credits

I used Illuminate\Support\Str as the basis of the StringConverters class`, many thanks Taylor Otwell and all contributors.