The collect function creates a collection instance from the given value:
<?php $collection = collect(['taylor', 'abigail']);
<?php         if (!empty($models)) {

            $dir = str_replace(app_path(), '', $directory);



            return collect($models)->map(function ($name) use ($dir) {

                if (strpos($name, '\\') !== false) {

                    return $name;

                }
<?php             });

        }



        return collect(File::allFiles($directory))->map(function (SplFileInfo $file) {

            if (!preg_match('/^namespace\s+([^;]+)/m', $file->getContents(), $matches)) {

                return null;

            }
<?php         static $fakerMethodNames = [];



        if (empty($fakerMethodNames)) {

            $fakerMethodNames = collect($this->generator->getProviders())

                ->flatMap(function(Base $provider) {

                    return $this->getNamesFromProvider($provider);

                })
<?php     protected function getNamesFromProvider(Base $provider)

    {

        return collect(get_class_methods($provider))

            ->reject(function(string $methodName) {

                return Str::startsWith($methodName, '__');

            })