27 lines
715 B
PHP
27 lines
715 B
PHP
<?php
|
|
namespace App\Service\Import\Specification;
|
|
use App\Service\Import\Interfaces\ColumnSpecificationInterface;
|
|
|
|
class NumericSpecification implements ColumnSpecificationInterface
|
|
{
|
|
private string $errorMessage ;
|
|
private string $pattern;
|
|
|
|
public function __construct(string $pattern, string $errorMessage)
|
|
{
|
|
$this->pattern = $pattern;
|
|
$this->errorMessage = $errorMessage;
|
|
}
|
|
|
|
public function isSatisfiedBy(string $value): bool
|
|
{
|
|
return preg_match($this->pattern, $value) === 1;
|
|
}
|
|
|
|
public function getErrorMessage(): string
|
|
{
|
|
return $this->errorMessage;
|
|
}
|
|
}
|
|
|