. */ namespace App\Services\CSV\File; use App\Services\Session\Constants; use App\Services\Storage\StorageService; use Illuminate\Contracts\Filesystem\FileNotFoundException; use League\Csv\Reader; /** * Class FileReader */ class FileReader { /** * Get a CSV file reader and fill it with data from CSV file. * * @return Reader * @throws FileNotFoundException */ public static function getReaderFromSession(): Reader { $content = StorageService::getContent(session()->get(Constants::UPLOAD_CSV_FILE)); // room for config return Reader::createFromString($content); } /** * @param string $content * * @return Reader */ public static function getReaderFromContent(string $content): Reader { return Reader::createFromString($content); } }