Skip to content

Commit

Permalink
Rename enableCellValueTrim to setShouldTrim
Browse files Browse the repository at this point in the history
  • Loading branch information
xanish committed Dec 23, 2021
1 parent 6c96eaf commit 0045669
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Validator/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Validator
*
* @var bool
*/
protected $trimCells = false;
protected $shouldTrim = false;

/**
* The array of custom error messages.
Expand Down Expand Up @@ -185,7 +185,7 @@ protected function passes(): bool
while (false !== ($row = fgetcsv($handle, 0, $this->delimiter))) {
++$this->currentRowLineNumber;

if ($this->trimCells) {
if ($this->shouldTrim) {
$row = array_map('trim', $row);
}

Expand Down Expand Up @@ -434,8 +434,8 @@ protected function getValue(string $attribute)
*
* @return void
*/
public function enableCellValueTrim(bool $trimValues = false)
public function setShouldTrim(bool $shouldTrim = false)
{
$this->trimCells = $trimValues;
$this->shouldTrim = $shouldTrim;
}
}
4 changes: 2 additions & 2 deletions tests/src/CsvValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testAlphaValidationRule()
'contact' => ['alpha'],
]);

$validator->enableCellValueTrim(true);
$validator->setShouldTrim(true);

$this->assertTrue($validator->fails());

Expand Down Expand Up @@ -74,7 +74,7 @@ public function testAlphaNumValidationRule()
'contact' => ['alpha_num'],
]);

$validator->enableCellValueTrim(true);
$validator->setShouldTrim(true);

$this->assertTrue($validator->fails());

Expand Down

0 comments on commit 0045669

Please sign in to comment.