Collapsar Gamma-Ray Bursts: how the luminosity function dictates the duration distribution