public static function changeKeyCase($data, int $case = null)
    {
        $properties = get_object_vars($data);
        foreach ($properties as &$key) {
            $value = & $data->$key;
            unset($data->$key);
            
            $changeCaseKey = ($case == CASE_UPPER) ? strtoupper($key) : strtolower($key);
            $data->$changeCaseKey = & $value;
        }
        
        return $data;
    }
public static function changeKeyCase($data, int $case = null)
    {
        $properties = get_object_vars($data);
        foreach ($properties as &$key) {
            $value = & $data->$key;
            unset($data->$key);
            
            $changeCaseKey = ($case == CASE_UPPER) ? strtoupper($key) : strtolower($key);
            $data->$changeCaseKey = & $value;
        }
        
        return $data;
    }
public static function changeKeyCase ( $ data , int $ case = null ) { $ properties = get_object_vars ( $ data ) ; foreach ( $ properties as & $ key ) { $ value = & $ data -> $ key ; unset ( $ data -> $ key ) ; $ changeCaseKey = ( $ case == CASE_UPPER ) ? strtoupper ( $ key ) : strtolower ( $ key ) ; $ data -> $ changeCaseKey = & $ value ; } return $ data ; }
Changes the case of all properties in an object

@param object $object
The object to work with

@param int $case
[optional]
Either CASE_UPPER or CASE_LOWER (default)

@return object an object with its properties lower or uppercased.
Changes the case of all properties in an object