cjrasmussen/objectify

Simple functions for converting associative arrays to objects and vice-versa

1.0.0 2024-06-30 01:58 UTC

This package is auto-updated.

Last update: 2024-11-05 15:18:25 UTC


README

Simple functions for converting associative arrays to objects and vice-versa.

There are better ways to do this for specific cases but this covers some extremely general cases easy enough.

Usage

use cjrasmussen\Objectify\Objectify;

$array = [
    'foo' => 'bar',
    'baz' => [
        'alpha' => 1,
        'beta' => 2,
    ],
];
$object = Objectify::toObject($array);

Installation

Simply add a dependency on cjrasmussen/objectify to your composer.json file if you use Composer to manage the dependencies of your project:

composer require cjrasmussen/objectify

Although it's recommended to use Composer, you can actually include the file(s) any way you want.

License

Objectify is MIT licensed.