Java like streams in PHP