ngfw / Recipe

Collection of PHP Functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object to recipe isn`t really converting to array

19th opened this issue · comments

commented

Is it worth to have such kind of method if it's just type casting?
If Object will be recursive, it won`t really convert it to array.

public static function objectToArray($object)  
{
     if (is_object($object)) {
          return (array) $object;
     } else {
          throw new \Exception("Not an object");
     }
 }

Maybe better to replace it with known "hack" with json encode and decode or remove it at all?

You are absolutely right!

Thank you!