Download the PHP package juanchosl/datatransfer without Composer
On this page you can find all versions of the php package juanchosl/datatransfer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juanchosl/datatransfer
More information about juanchosl/datatransfer
Files in juanchosl/datatransfer
Package datatransfer
Short Description A small, lightweight utility to read values and properties from distinct sources using the same methodology
License MIT
Homepage https://github.com/JuanchoSL/DataTransfer
Informations about the package datatransfer
DataTransfer
Description
A small, lightweight utility to read values and properties from distinct sources using the same methodology and convert it to a standard DTO. Include a second tool that can convert any of DTOs to any of the know formats, creating a simple format converter from format A to format B.
Install
How use it
Load composer autoload and use it
Data Transfer Objects
Using the provided Factory
The $element parameter can be:
- array indexed or associtive
- object that implements JsonSerializable interface
- string with serialized object or array
- filepath containing a serialized object or array
- json encoded object or array
- json filepath with json extension containing a json encoded object or array
- SimpleXMLElement object
- XML string or filepath with xml extension
- CSV string or filepath with csv extension
- INI string or filepath with ini extension
- YAML string or filepath with yml or yaml extension (require yaml php extension)
- primitive value
Using a filepath
Open and convert the contents included into file, alternatively you can specify the Format if the extension is not knowed
Using a string
Try to detect and convert the contents included into string (json encoded, serialized object or array, xml, csv, yaml), alternatively you can specify the Format if the type is INI
Using a mime-type
You can try passing an iterable number of strings as standard mimetypes ir order to process with the first compatible
Using a trasversable element
Detect and convert the trasversable element (object or array)
Using a specific repository
Alternative you can use the distincts repositories
Available origins and repositories
Type | Compatibility | Reader |
---|---|---|
Array | filepath | array | string from array serialized | ArrayDataTransfer |
stdClass | filepath | object | string from object serialized | ObjectDataTransfer |
CSV | filepath | array of lines | string | CsvDataTransfer(,) or ExcelCsvDataTransfer(;) |
INI | filepath | string | IniDataTransfer |
JSON | filepath | string | JsonDataTransfer |
XML | filepath | string | SimpleXmlElement | XmlDataTransfer |
YAML | filepath | string | YamlDataTransfer |
XLSX | filepath | string | ExcelXlsxDataTransfer |
The $element parameter needs to be the required type for the selected repo
Is more efective use a magic factory in order to avoid know the type of the original data, and you can change it with no need to adapt your existing code.
The resultant $dto variable is a recursive data transfer object, iterable, countable, clonable and json serializable
Use data
Data Converters
You can convert any DataTransferObject to a standar format, as:
- array
- stdClass
- SimpleXMLElement
- json
- xml
- ini
- yaml
- csv
- excel csv
- xlsx
Using the provided Factory
Using a mime-type
You can try passing an iterable number of strings as standard mimetypes ir order to convert with the first compatible
Using a specific converter
Alternative you can use the distincts converters
The available converters are:
- CsvConverter (,)
- ExcelCsvConverter(;)
- ExcelXlsxConverter
- JsonConverter
- XmlConverter
- YamlConverter
- IniConverter
- ArrayConverter
- ObjectConverter
- XmlObjectConverter
All versions of datatransfer with dependencies
ext-mbstring Version *
ext-json Version *
juanchosl/validators Version 1.0.*
juanchosl/exceptions Version 1.0.*
juanchosl/httpheaders Version 1.0.*
psr/http-server-handler Version 1.0.*
composer-runtime-api Version ^2.2