public static function toObject($array, $class = \stdClass::class)
    {
        $object = new $class;

        foreach ($array as $name => $value) {
            $name = trim($name);

            if (!$name || is_numeric($name)) {
                continue;
            }

            $object->$name = \is_array($value) ? self::toObject($value) : $value;
        }

        return $object;
    }