Why must it have been written as a metaphor? Why could it not be just based on the common view? It was sufficient for its day. It is only since science got involved that people have looked for any other meanings.
In the beginning, God created the heavens and the earth… most of the rest is poetic padding. God created rather than things created themselves (Oops Evolution) The exact sequence and minute details are not what is looked for here.
On the 7th day God rested…
In the comparable Babylonian story there are 8 days and no rest. But, if you look, in the Genesis version God does 2 things on 2 days, to give Him time to rest on the 7th.
By coincidence the modern view is that Genesis 1 was written during the exhile in Babylon
Richard