filmtools/parser

1.1.1 2019-08-31 19:20 UTC

This package is auto-updated.

Last update: 2024-11-29 05:56:56 UTC


README

Installation

$ composer require filmtools/parser

Usage

Creating the Parser object

<?php
use FilmTools\Parser\ParserFactory;
use FilmTools\Parser\ParserExceptionInterface;

$factory = new ParserFactory;

try { 
	$parser = $factory("data.csv");
}
catch (ParserExceptionInterface $e) {
  echo $e->getMessage();
  // "Invalid file extension ..."
}

Parsing the data

try {
	$records = $parser->parse("data.csv");
  $records = $parser->parseString( file_get_contents("data.csv"));
  
	foreach($records as $row):
  	// Do things with \Traversable
	endforeach;  
}
catch (ParserExceptionInterface $e) {
  echo $e->getMessage();
  // "File not found ..." 
  // or s.th. like that
}

Unit Tests

Nope, sorry … cough