Skip to content

Commit

Permalink
Docblock improvements, removing inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed May 9, 2015
1 parent a07d322 commit 2599f48
Show file tree
Hide file tree
Showing 48 changed files with 563 additions and 185 deletions.
3 changes: 3 additions & 0 deletions src/Exception/DuplicateHeadersException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Ddeboer\DataImport\Exception;

/**
* @author David de Boer <david@ddeboer.nl>
*/
class DuplicateHeadersException extends ReaderException implements ExceptionInterface
{
public function __construct(array $duplicates)
Expand Down
3 changes: 2 additions & 1 deletion src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
/**
* Base exception
*
* @author David de Boer <david@ddeboer.nl>
*/
interface ExceptionInterface
{
}

}
2 changes: 1 addition & 1 deletion src/Exception/MappingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
class MappingException extends \Exception implements ExceptionInterface
{

}
}
4 changes: 4 additions & 0 deletions src/Exception/ReaderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Ddeboer\DataImport\Exception;

/**
* @author David de Boer <david@ddeboer.nl>
*/
class ReaderException extends UnexpectedValueException implements ExceptionInterface
{

}
1 change: 1 addition & 0 deletions src/Exception/SourceNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
*/
class SourceNotFoundException extends \Exception implements ExceptionInterface
{

}
16 changes: 7 additions & 9 deletions src/Exception/UnexpectedTypeException.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Ddeboer\DataImport\Exception;

/**
* @author David de Boer <david@ddeboer.nl>
*/
class UnexpectedTypeException extends \UnexpectedValueException implements ExceptionInterface
{
/**
* @param mixed $value
* @param string $expectedType
*/
public function __construct($value, $expectedType)
{
parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value)));
Expand Down
4 changes: 4 additions & 0 deletions src/Exception/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

namespace Ddeboer\DataImport\Exception;

/**
* @author David de Boer <david@ddeboer.nl>
*/
class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface
{

}

19 changes: 19 additions & 0 deletions src/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,42 @@

use Symfony\Component\Validator\ConstraintViolationListInterface;

/**
* @author Markus Bachmann <markus.bachmann@bachi.biz>
*/
class ValidationException extends \Exception implements ExceptionInterface
{
/**
* @var ConstraintViolationListInterface
*/
private $violations;

/**
* @var int
*/
private $lineNumber;

/**
* @param ConstraintViolationListInterface $list
* @param int $line
*/
public function __construct(ConstraintViolationListInterface $list, $line)
{
$this->violations = $list;
$this->lineNumber = $line;
}

/**
* @return ConstraintViolationListInterface
*/
public function getViolations()
{
return $this->violations;
}

/**
* @return int
*/
public function getLineNumber()
{
return $this->lineNumber;
Expand Down
4 changes: 4 additions & 0 deletions src/Exception/WriterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Ddeboer\DataImport\Exception;

/**
* @author David de Boer <david@ddeboer.nl>
*/
class WriterException extends \Exception implements ExceptionInterface
{

}
12 changes: 11 additions & 1 deletion src/Filter/DateTimeThresholdFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/**
* This filter can be used to filter out some items from a specific date. Useful
* to do incremental imports
*
* @author Grégoire Paris
*/
class DateTimeThresholdFilter
{
Expand All @@ -32,6 +34,12 @@ class DateTimeThresholdFilter
*/
protected $priority;

/**
* @param DateTimeValueConverter $valueConverter
* @param \DateTime|null $threshold
* @param string $timeColumnName
* @param int $priority
*/
public function __construct(
DateTimeValueConverter $valueConverter,
\DateTime $threshold = null,
Expand All @@ -45,7 +53,7 @@ public function __construct(
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function __invoke(array $item)
{
Expand All @@ -62,6 +70,8 @@ public function __invoke(array $item)
/**
* Useful if you build a filter service, and want to set the threshold
* dynamically afterwards.
*
* @return $this
*/
public function setThreshold(\DateTime $value)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Filter/OffsetFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class OffsetFilter
protected $maxLimitHit = false;

/**
* Constructor
*
* @param int $offset 0-based index of the item to start read from
* @param int|null $limit Maximum count of items to read. null = no limit
*/
Expand All @@ -48,7 +46,7 @@ public function __construct($offset = 0, $limit = null)
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function __invoke(array $item)
{
Expand Down
42 changes: 42 additions & 0 deletions src/Filter/ValidatorFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,53 @@
use Symfony\Component\Validator\Constraints;
use Ddeboer\DataImport\Exception\ValidationException;

/**
* @author Markus Bachmann <markus.bachmann@bachi.biz>
*/
class ValidatorFilter
{
/**
* @var ValidatorInterface
*/
private $validator;

/**
* @var boolean
*/
private $throwExceptions = false;

/**
* @var int
*/
private $line = 1;

/**
* @var boolean
*/
private $strict = true;

/**
* @var array
*/
private $constraints = array();

/**
* @var array
*/
private $violations = array();

/**
* @param ValidatorInterface $validator
*/
public function __construct(ValidatorInterface $validator)
{
$this->validator = $validator;
}

/**
* @param string $field
* @param Constraint $constraint
*/
public function add($field, Constraint $constraint)
{
if (!isset($this->constraints[$field])) {
Expand All @@ -35,21 +63,35 @@ public function add($field, Constraint $constraint)
$this->constraints[$field][] = $constraint;
}

/**
* @param boolean $flag
*/
public function throwExceptions($flag = true)
{
$this->throwExceptions = $flag;
}

/**
* @param boolean $strict
*/
public function setStrict($strict)
{
$this->strict = $strict;
}

/**
* @return array
*/
public function getViolations()
{
return $this->violations;
}

/**
* @param array $item
*
* @return boolean
*/
public function __invoke(array $item)
{
if (!$this->strict) {
Expand Down
22 changes: 12 additions & 10 deletions src/Reader/CsvReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ class CsvReader implements CountableReaderInterface, \SeekableIterator
protected $duplicateHeadersFlag;

/**
* Construct CSV reader
*
* @param \SplFileObject $file CSV file
* @param string $delimiter Delimiter
* @param string $enclosure Enclosure
* @param string $escape Escape characters
* @param \SplFileObject $file
* @param string $delimiter
* @param string $enclosure
* @param string $escape
*/
public function __construct(\SplFileObject $file, $delimiter = ',', $enclosure = '"', $escape = '\\')
{
Expand Down Expand Up @@ -250,6 +248,9 @@ public function key()
return $this->file->key();
}

/**
* {@inheritdoc}
*/
public function seek($pointer)
{
$this->file->seek($pointer);
Expand Down Expand Up @@ -295,7 +296,7 @@ public function getErrors()
/**
* Does the reader contain any invalid rows?
*
* @return bool
* @return boolean
*/
public function hasErrors()
{
Expand All @@ -305,7 +306,7 @@ public function hasErrors()
/**
* Should the reader use strict parsing?
*
* @return bool
* @return boolean
*/
public function isStrict()
{
Expand All @@ -315,7 +316,7 @@ public function isStrict()
/**
* Set strict parsing
*
* @param bool $strict
* @param boolean $strict
*
* @return CsvReader
*/
Expand All @@ -331,7 +332,8 @@ public function setStrict($strict)
*
* @param int $rowNumber Row number
*
* @return array Column headers
* @return array
*
* @throws DuplicateHeadersException
*/
protected function readHeaderRow($rowNumber)
Expand Down
Loading

0 comments on commit 2599f48

Please sign in to comment.