Exemple #1
0
 /**
  * @param null|int $minLength
  * @param null|int $maxLength
  * @param null|string $pattern
  * @param null|string $format
  */
 private function applyStringOptions($minLength = null, $maxLength = null, $pattern = null, $format = null)
 {
     $minLength = (int) $minLength;
     $maxLength = (int) $maxLength;
     if ($maxLength > 0) {
         $this->maxLength = $maxLength;
         $this->minLength = NumberUtils::bound($minLength, 0, $this->maxLength);
     } else {
         // arbitrary string minimum range
         $this->minLength = NumberUtils::bound($minLength, 0, $this->type->getMaxBytes());
     }
     if (null !== $pattern) {
         $this->pattern = '/' . trim($pattern, '/') . '/';
     }
     if (null !== $format && in_array($format, Format::values())) {
         $this->format = Format::create($format);
     } else {
         $this->format = Format::UNKNOWN();
     }
 }