function Count::__construct
Same name in this branch
- 11.1.x vendor/phpunit/phpunit/src/Framework/Constraint/Cardinality/Count.php \PHPUnit\Framework\Constraint\Count::__construct()
Parameters
int<0, max>|array<string,mixed>|null $exactly The exact expected number of elements:
int<0, max>|null $min Minimum expected number of elements:
positive-int|null $max Maximum expected number of elements:
positive-int|null $divisibleBy The number the collection count should be divisible by:
string[]|null $groups:
array<mixed,string> $options:
Overrides Constraint::__construct
2 calls to Count::__construct()
- CountConstraint::__construct in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ CountConstraint.php - Initializes the constraint with options.
- CountConstraint::__construct in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ CountConstraint.php - Initializes the constraint with options.
1 method overrides Count::__construct()
- CountConstraint::__construct in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ CountConstraint.php - Initializes the constraint with options.
File
-
vendor/
symfony/ validator/ Constraints/ Count.php, line 53
Class
- Count
- Validates a collection's element count.
Namespace
Symfony\Component\Validator\ConstraintsCode
public function __construct(int|array|null $exactly = null, ?int $min = null, ?int $max = null, ?int $divisibleBy = null, ?string $exactMessage = null, ?string $minMessage = null, ?string $maxMessage = null, ?string $divisibleByMessage = null, ?array $groups = null, mixed $payload = null, array $options = []) {
if (\is_array($exactly)) {
$options = array_merge($exactly, $options);
$exactly = $options['value'] ?? null;
}
$min ??= $options['min'] ?? null;
$max ??= $options['max'] ?? null;
unset($options['value'], $options['min'], $options['max']);
if (null !== $exactly && null === $min && null === $max) {
$min = $max = $exactly;
}
parent::__construct($options, $groups, $payload);
$this->min = $min;
$this->max = $max;
$this->divisibleBy = $divisibleBy ?? $this->divisibleBy;
$this->exactMessage = $exactMessage ?? $this->exactMessage;
$this->minMessage = $minMessage ?? $this->minMessage;
$this->maxMessage = $maxMessage ?? $this->maxMessage;
$this->divisibleByMessage = $divisibleByMessage ?? $this->divisibleByMessage;
if (null === $this->min && null === $this->max && null === $this->divisibleBy) {
throw new MissingOptionsException(\sprintf('Either option "min", "max" or "divisibleBy" must be given for constraint "%s".', __CLASS__), [
'min',
'max',
'divisibleBy',
]);
}
}