private function File::normalizeBinaryFormat in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Constraints/File.php \Symfony\Component\Validator\Constraints\File::normalizeBinaryFormat()
2 calls to File::normalizeBinaryFormat()
- File::__construct in vendor/
symfony/ validator/ Constraints/ File.php - Initializes the constraint with options.
- File::__set in vendor/
symfony/ validator/ Constraints/ File.php - Sets the value of a lazily initialized option.
File
- vendor/
symfony/ validator/ Constraints/ File.php, line 89
Class
- File
- @Target({"PROPERTY", "METHOD", "ANNOTATION"})
Namespace
Symfony\Component\Validator\ConstraintsCode
private function normalizeBinaryFormat($maxSize) {
if (ctype_digit((string) $maxSize)) {
$this->maxSize = (int) $maxSize;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
}
elseif (preg_match('/^\\d++k$/i', $maxSize)) {
$this->maxSize = $maxSize * 1000;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
}
elseif (preg_match('/^\\d++M$/i', $maxSize)) {
$this->maxSize = $maxSize * 1000000;
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
}
elseif (preg_match('/^\\d++Ki$/i', $maxSize)) {
$this->maxSize = $maxSize << 10;
$this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat;
}
elseif (preg_match('/^\\d++Mi$/i', $maxSize)) {
$this->maxSize = $maxSize << 20;
$this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat;
}
else {
throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size', $this->maxSize));
}
}