Skip to content

Commit

Permalink
Merge da0c1b0 into acb218b
Browse files Browse the repository at this point in the history
  • Loading branch information
courtney-miles committed Aug 22, 2018
2 parents acb218b + da0c1b0 commit 46883c8
Show file tree
Hide file tree
Showing 16 changed files with 182 additions and 373 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

[![Build Status](https://travis-ci.org/courtney-miles/slurp.svg?branch=master)](https://travis-ci.org/courtney-miles/slurp) [![Coverage Status](https://coveralls.io/repos/github/courtney-miles/slurp/badge.svg?branch=master)](https://coveralls.io/github/courtney-miles/slurp?branch=master)

Slurp is a simple PHP ETL (extract, transform, load) tool that can validate prior to loading source data
Slurp is a simple PHP ETL (extract, transform, load) tool that can validate prior to loading source data.

## Known limitations

* A CSV file with an inconsistent number of values per row will be silently handled, where it would be preferable to raise an exception.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"require": {
"php": "7.1 - 7.2",
"symfony/validator": "^4.1.0",
"ext-PDO": "*"
"ext-PDO": "*",
"league/csv": "^9.0"
},
"require-dev": {
"phpunit/phpunit": "^6",
Expand Down
69 changes: 68 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

169 changes: 0 additions & 169 deletions src/Extract/CsvFileExtractor.php

This file was deleted.

45 changes: 45 additions & 0 deletions src/Extract/CsvFileExtractor/CsvFileExtractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Author: Courtney Miles
* Date: 15/08/18
* Time: 7:08 PM
*/

namespace MilesAsylum\Slurp\Extract\CsvFileExtractor;

use League\Csv\Reader;
use MilesAsylum\Slurp\Extract\ExtractorInterface;

class CsvFileExtractor implements ExtractorInterface
{
/**
* @var Reader
*/
private $csvReader;

private $headers = [];

public function __construct(Reader $csvReader)
{
$this->csvReader = $csvReader;
}

/**
* Loads the first row in the CSV file as the headers.
* @throws \League\Csv\Exception
*/
public function loadHeadersFromFile() : void
{
$this->csvReader->setHeaderOffset(0);
}

public function setHeaders(array $headers) : void
{
$this->headers = $headers;
}

public function getIterator() : \Iterator
{
return $this->csvReader->getRecords($this->headers);
}
}
13 changes: 0 additions & 13 deletions src/Extract/Exception/ExceptionInterface.php

This file was deleted.

13 changes: 0 additions & 13 deletions src/Extract/Exception/MalformedCsvException.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Extract/ExtractorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
namespace MilesAsylum\Slurp\Extract;


interface ExtractorInterface extends \Iterator
interface ExtractorInterface extends \IteratorAggregate
{
}
Loading

0 comments on commit 46883c8

Please sign in to comment.