Skip to content

Commit

Permalink
Adds CountableReaderInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Jan 29, 2015
1 parent c96f66e commit 54f1ded
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Ddeboer/DataImport/Reader/ArrayReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* @author David de Boer <david@ddeboer.nl>
*/
class ArrayReader extends \ArrayIterator implements ReaderInterface
class ArrayReader extends \ArrayIterator implements CountableReaderInterface
{
/**
* {@inheritdoc}
Expand Down
13 changes: 13 additions & 0 deletions src/Ddeboer/DataImport/Reader/CountableReaderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Ddeboer\DataImport\Reader;

/**
* Reader that provides the count of total items
*
* @author David de Boer <david@ddeboer.nl>
*/
interface CountableReaderInterface extends ReaderInterface, \Countable
{
// Don't add count() to interface: see https://github.com/ddeboer/data-import/pull/5
}
2 changes: 1 addition & 1 deletion src/Ddeboer/DataImport/Reader/CsvReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @author David de Boer <david@ddeboer.nl>
*/
class CsvReader implements ReaderInterface, \SeekableIterator
class CsvReader implements CountableReaderInterface, \SeekableIterator
{
const DUPLICATE_HEADERS_INCREMENT = 1;
const DUPLICATE_HEADERS_MERGE = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/Ddeboer/DataImport/Reader/DbalReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Reads data through the Doctrine DBAL
*/
class DbalReader implements ReaderInterface
class DbalReader implements CountableReaderInterface
{
/** @var Connection */
private $connection;
Expand Down
2 changes: 1 addition & 1 deletion src/Ddeboer/DataImport/Reader/DoctrineReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Reads entities through the Doctrine ORM
*
*/
class DoctrineReader implements ReaderInterface
class DoctrineReader implements CountableReaderInterface
{
protected $objectManager;
protected $objectName;
Expand Down
2 changes: 1 addition & 1 deletion src/Ddeboer/DataImport/Reader/ExcelReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @link http://phpexcel.codeplex.com/
* @link https://github.com/logiQ/PHPExcel
*/
class ExcelReader implements ReaderInterface
class ExcelReader implements CountableReaderInterface
{
protected $worksheet;
protected $headerRowNumber;
Expand Down
2 changes: 1 addition & 1 deletion src/Ddeboer/DataImport/Reader/OneToManyReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Adam Paterson <hello@adampaterson.co.uk>
* @author Aydin Hassan <aydin@hotmail.co.uk>
*/
class OneToManyReader implements ReaderInterface
class OneToManyReader implements CountableReaderInterface
{
/**
* @var ReaderInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Ddeboer/DataImport/Reader/PdoReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/**
* Reads data through PDO
*/
class PdoReader implements ReaderInterface
class PdoReader implements CountableReaderInterface
{
/**
* @var \PDO
Expand Down
8 changes: 4 additions & 4 deletions src/Ddeboer/DataImport/Writer/ConsoleProgressWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Ddeboer\DataImport\Writer;

use Ddeboer\DataImport\Reader\ReaderInterface;
use Ddeboer\DataImport\Reader\CountableReaderInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\ProgressBar;

Expand All @@ -28,7 +28,7 @@ class ConsoleProgressWriter extends AbstractWriter
protected $verbosity;

/**
* @var ReaderInterface
* @var CountableReaderInterface
*/
protected $reader;

Expand All @@ -39,13 +39,13 @@ class ConsoleProgressWriter extends AbstractWriter

/**
* @param OutputInterface $output
* @param ReaderInterface $reader
* @param CountableReaderInterface $reader
* @param string $verbosity
* @param int $redrawFrequency
*/
public function __construct(
OutputInterface $output,
ReaderInterface $reader,
CountableReaderInterface $reader,
$verbosity = 'debug',
$redrawFrequency = 1
) {
Expand Down

0 comments on commit 54f1ded

Please sign in to comment.