26 lines
582 B
PHP
26 lines
582 B
PHP
<?php
|
|
|
|
namespace App\Service\Import\Specification;
|
|
|
|
use App\Service\Import\Interfaces\ColumnSpecificationInterface;
|
|
|
|
class RequiredColumnSpecification implements ColumnSpecificationInterface
|
|
{
|
|
private string $errorMessage;
|
|
|
|
public function __construct(string $errorMessage = 'Ce champ est requis.')
|
|
{
|
|
$this->errorMessage = $errorMessage;
|
|
}
|
|
|
|
public function isSatisfiedBy(mixed $value): bool
|
|
{
|
|
return !empty($value) && trim($value) !== '';
|
|
}
|
|
|
|
public function getErrorMessage(): string
|
|
{
|
|
return $this->errorMessage;
|
|
}
|
|
}
|