php-extended/php-api-endpoint-csv-object

A library that implements the php-extended/php-api-endpoint-csv-interface library

4.0.1 2022-06-06 16:48 UTC

README

A library that implements the php-extended/php-api-endpoint-csv-interface library.

coverage build status

Installation

The installation of this library is made via composer. Download composer.phar from their website. Then add to your composer.json :

	"require": {
		...
		"php-extended/php-api-endpoint-csv-object": "^4"
		...
	}

Then run php composer.phar update to install this library. The autoloading of all classes of this library is made through composer's autoloader.

Basic Usage

This library is made to be extended. The base Endpoint implementation is a generic object that is made to ease the transform into a really useful endpoint that may be something like :


use PhpExtended\Endpoint\LocalCsvEndpoint;

class MyEndpoint extends LocalCsvEndpoint
{
	
	/**
	 * @return \Iterator<Foo>
	 */
	public function getFoos() : \Iterator
	{
		return $this->getObject(Foo::class, __DIR__.'/foos.csv');
	}
	
}

Where __DIR__./'foos.csv' is a file that contains a foo per row of csv data, where the fields are in order with the constructor.

License

MIT (See license file).