public static function insertBeforeKey(array &$array, string $key, string $newKey, $newValue)
    {
        if (\array_key_exists($key, $array)) {
            $new = [];

            foreach ($array as $k => $value) {
                if ($k === $key) {
                    $new[$newKey] = $newValue;
                }
                $new[$k] = $value;
            }
            $array = $new;
        } else {
            $array[$newKey] = $newValue;
        }
    }