2016-05-20 12:03:28 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Deblan\CsvValidator;
|
|
|
|
|
|
|
|
use Symfony\Component\Validator\ConstraintViolation;
|
|
|
|
|
|
|
|
/**
|
2016-12-02 13:50:07 +01:00
|
|
|
* Class Violation.
|
|
|
|
*
|
2016-05-20 12:03:28 +02:00
|
|
|
* @author Simon Vieille <simon@deblan.fr>
|
|
|
|
*/
|
|
|
|
class Violation
|
|
|
|
{
|
|
|
|
/**
|
2016-12-02 13:50:07 +01:00
|
|
|
* @var int
|
2016-05-20 12:03:28 +02:00
|
|
|
*/
|
|
|
|
protected $line;
|
|
|
|
|
|
|
|
/**
|
2016-12-02 13:50:07 +01:00
|
|
|
* @var int
|
2016-05-20 12:03:28 +02:00
|
|
|
*/
|
|
|
|
protected $column;
|
2016-12-02 13:50:07 +01:00
|
|
|
|
2016-05-20 12:03:28 +02:00
|
|
|
/**
|
|
|
|
* @var ConstraintViolation
|
|
|
|
*/
|
|
|
|
protected $violation;
|
|
|
|
|
|
|
|
/**
|
2016-12-02 13:50:07 +01:00
|
|
|
* Constructor.
|
2016-05-20 12:03:28 +02:00
|
|
|
*
|
2016-12-02 13:50:07 +01:00
|
|
|
* @param int $line The line of the violation
|
|
|
|
* @param int $column The column of the violation
|
2016-05-20 12:03:28 +02:00
|
|
|
* @param ConstraintViolation $violation The violation
|
|
|
|
*/
|
|
|
|
public function __construct($line, $column, ConstraintViolation $violation)
|
|
|
|
{
|
|
|
|
$this->setLine($line)
|
|
|
|
->setColumn($column)
|
|
|
|
->setViolation($violation);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $line
|
2016-12-02 13:50:07 +01:00
|
|
|
*
|
2016-05-20 12:03:28 +02:00
|
|
|
* @return Violation
|
|
|
|
*/
|
|
|
|
public function setLine($line)
|
|
|
|
{
|
|
|
|
$this->line = (int) $line;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int $line
|
|
|
|
*/
|
|
|
|
public function getLine()
|
|
|
|
{
|
|
|
|
return $this->line;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $column
|
2016-12-02 13:50:07 +01:00
|
|
|
*
|
2016-05-20 12:03:28 +02:00
|
|
|
* @return Violation
|
|
|
|
*/
|
|
|
|
public function setColumn($column)
|
|
|
|
{
|
2016-05-22 23:22:12 +02:00
|
|
|
if ($column !== null) {
|
|
|
|
$column = (int) $column;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->column = $column;
|
2016-05-20 12:03:28 +02:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int $column
|
|
|
|
*/
|
|
|
|
public function getColumn()
|
|
|
|
{
|
|
|
|
return $this->column;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ConstraintViolation $violation
|
2016-12-02 13:50:07 +01:00
|
|
|
*
|
2016-05-20 15:09:52 +02:00
|
|
|
* @return Violation
|
2016-05-20 12:03:28 +02:00
|
|
|
*/
|
|
|
|
public function setViolation(ConstraintViolation $violation)
|
|
|
|
{
|
|
|
|
$this->violation = $violation;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-20 15:09:52 +02:00
|
|
|
* @return ConstraintViolation
|
2016-05-20 12:03:28 +02:00
|
|
|
*/
|
|
|
|
public function getViolation()
|
|
|
|
{
|
|
|
|
return $this->violation;
|
|
|
|
}
|
|
|
|
}
|