In-Place, recursive conversion of stdClass keys in snake_Case to camelCase

@param object $snakeObject Object with snake_properties
@return object
555363
final public function objectPropertiesToCamel($snakeObject)
    {
        // hold the object of new values
        $camelObject = new \stdClass();
        foreach ($snakeObject as $key => $value) {
            // tricky recursive for objects or arrays
            if (is_object($value)) {
                $value = $this->objectPropertiesToCamel($value);
            } elseif (is_array($value)) {
                $value = $this->arrayKeysToCamel($value);
            }
            $camelObject->{$this->camelize($key)} = $value;
            unset($snakeObject[$key]);
        }
        return $camelObject;
    }
618739
public function populateDefaultRelations(DataObject $object)
    {
        foreach ($object->hasOne() as $name => $class) {
            
            if ($id = $this->getDefaultRelation($class)) {
                $object->{$name . 'ID'} = $id;
            }
            
        }
        
        return $object;
    }
1355647
public static function objToSnakeArray($object, $blackList = [])
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('Not an object');
        }

        return array_reduce(
            self::getAllProperties($object, $blackList),
            function (
                array $result,
                \ReflectionProperty $property
            ) use (
                $object
            ) {
                $property->setAccessible(true);

                $field = $property->getName();
                $value = $property->getValue($object);
                $value = self::transformValue($value);

                if ($object instanceof WithNullableFields) {
                    if (is_null($value) && !$object->isNullable($field)) {
                        return $result;
                    }

                    if ($object->isNullable($field) && !$object->isValueChanged($field)) {
                        return $result;
                    }
                } elseif (is_null($value)) {
                    return $result;
                }


                $result[Str::snake($field)] = $value;

                $property->setAccessible(false);

                return $result;
            },
            []
        );
    }
984288
public function toObject(bool $recursive = false) : \stdClass
    {
        $o = new \stdClass();
        if (!$recursive) {
            foreach ($this->explorableIndex as $property) {
                $o->{$property} = $this->{$property};
            }
        } else {
            foreach ($this->explorableIndex as $property) {
                $value = $this->{$property};
                $o->{$property} = !($value instanceof Explorable) ? $value : $value->toObject(true);
            }
        }
        return $o;
    }
608353
private static function getModelFromDBObject($dbObject)
    {
        $modelName = get_called_class();
        $object = new $modelName();
        foreach ($dbObject as $column => $val) {
            $object->$column = $val;
        }

        return $object;
    }
155012
public function snakeFormat()
    {
        $snake = new \stdClass;
        $rawValues = get_object_vars($this);

        foreach ($rawValues as $property => $value){
            $snake->{Str::snake($property)} = $value;
        }

        return $snake;
    }
181321
public static function fromDomainObject($domainObject)
    {
        if (!is_object($domainObject)) {
            throw new InvalidDomainObjectException('$domainObject must be an object.');
        }

        try {
            if ($domainObject instanceof HierarchicalDomainObjectInterface) {
                return new self(
                    $domainObject->getHierarchicalObjectIdentifiers(),
                    $domainObject->getObjectIdentifier(),
                    ClassUtils::getRealClass($domainObject)
                );
            }

            return parent::fromDomainObject($domainObject);
        } catch (\InvalidArgumentException $invalid) {
            throw new InvalidDomainObjectException($invalid->getMessage(), 0, $invalid);
        }

        throw new InvalidDomainObjectException('$domainObject must either implement the HierarchicalDomainObjectInterface, DomainObjectInterface, or have a method named "getId".');
    }
82796
public static function getClass($object) {
    if (!is_object($object))
      throw new \Psc\Exception('Cannot get Class from non-object value. '.self::varInfo($object));
    
    return get_class($object);
  }
131105
protected function convertArrayToSnakeCase(array $input):array
    {
        $converted = [];

        foreach ($input as $key => $value) {
            $converted[snake_case($key)] = $value;
        }

        return $converted;
    }
925133
protected function convertToSnakeCase($input)
    {
        if ($this->convertToSnakeCaseIsDisabled()) {
            return;
        }

        if (is_null($input)) {
            return null;
        } elseif (is_array($input)) {
            return $this->convertArrayToSnakeCase($input);
        }

        return snake_case($input);
    }
1065538
final public function arrayKeysToCamel(array $snakeArray)
    {
        // hold the array of new values
        $camelArray = [];
        foreach ($snakeArray as $key => $value) {
            // tricky recursive
            if (is_array($value)) {
                $value = $this->arrayKeysToCamel($value);
            }
            $camelArray[$this->camelize($key)] = $value;
            unset($snakeArray[$key]);
        }
        return $camelArray;
    }
864457
protected function getKey($key, $class)
    {
        if ($key === null || !is_string($key)) {
            $class_path = (is_string($class)) ? $class : get_class($class);

            $key = explode('\\', $class_path);
            $key = end($key);
        }

        return Helper::snakeCase($key);
    }
681495
public static function snakecaseToCamelcase(string $string, bool $lower = false): string
    {
        $words = explode('_', $string);

        array_walk($words, function (&$word, $index) {
            $word = ucfirst($word);
        });

        if ($lower) {
            return lcfirst(implode($words));
        }

        return implode($words);
    }
1212176
public static function snakeCase(string $value, bool $toLowerCase = false, string $separator = '_'): string
    {
        $replace = strtolower(preg_replace(
            ['/\s+/', '/\s/', '/(?|([a-z\d])([A-Z])|([^\^])([A-Z][a-z]))/', '/[-_]+/'],
            [' ', $separator, '$1' . $separator . '$2', $separator],
            trim($value)
        ));
        return $toLowerCase ? strtolower($replace) : $replace;
    }
1021341
public static function fromObject($object)
    {
        if (\is_object($object)) {
            $object = (array)$object;
        }
        if (\is_array($object)) {
            $array = [];
            foreach ($object as $key => $value) {
                $array[$key] = self::fromObject($value);
            }
        } else {
            $array = $object;
        }
        return $array;
    }
396472
protected function sortObject($object)
    {
        $sort_array = get_object_vars($object);
        ksort($sort_array);

        $new_object = new stdClass();
        foreach ($sort_array as $key => $value) {
            if (is_object($value)) {
                $value = $this->sortObject($value);
            }
            $new_object->$key = $value;
        }

        unset($sort_array);
        unset($object);

        return $new_object;
    }
469740
public static function createFromMutable(\ArrayObject $arrayObject) : ImmutableArrayObject
    {
        return new static($arrayObject->getArrayCopy(), $arrayObject->getFlags(), $arrayObject->getIteratorClass());
    }