Compact objects from gravitational collapse: an analytical toy model